client

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 5 Imported by: 0

README

grpc client

Generic grpc client.

Example of use

	import "github.com/18721889353/sunshine/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/18721889353/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