client

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 5 Imported by: 0

README

grpc client

Generic grpc client.

Example of use

	import "gitee.com/yzsunjianguo/sponge/pkg/grpc/client"

	conn, err := client.Dial(context.Background(), "127.0.0.1:8282",
		//client.WithServiceDiscover(builder),
		//client.WithLoadBalance(),
		//client.WithSecure(credentials),
		//client.WithUnaryInterceptor(unaryInterceptors...),
		//client.WithStreamInterceptor(streamInterceptors...),
	)

Examples of practical use https://github.com/yzsunjianguo/grpc_examples/blob/main/usage/client/main.go

Documentation

Overview

Package client is generic grpc client-side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(ctx context.Context, endpoint string, opts ...Option) (*grpc.ClientConn, error)

Dial to grpc server

Types

type Option

type Option func(*options)

Option client option func

func WithLoadBalance

func WithLoadBalance() Option

WithLoadBalance set load balance

func WithSecure

func WithSecure(credential credentials.TransportCredentials) Option

WithSecure set secure

func WithServiceDiscover

func WithServiceDiscover(builders ...resolver.Builder) Option

WithServiceDiscover set service discover

func WithStreamInterceptor

func WithStreamInterceptor(interceptors ...grpc.StreamClientInterceptor) Option

WithStreamInterceptor set stream interceptor

func WithUnaryInterceptor

func WithUnaryInterceptor(interceptors ...grpc.UnaryClientInterceptor) Option

WithUnaryInterceptor set unary interceptor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL