v0.0.0-...-35495f1 Latest Latest

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 22 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Client

type Client[T any] struct {
	// contains filtered or unexported fields

func NewDefaultClient

func NewDefaultClient[T any](endpoint, serverName string, generateClientFunc GenerateClientFunc[T], opts ...Option) *Client[T]

func (*Client[T]) NextClient

func (c *Client[T]) NextClient(ctx context.Context) (t T, err error)

NextClient 获得下一个client,通过这个方法,会获得最终的参数

func (*Client[T]) RebuildGrpcOpts

func (c *Client[T]) RebuildGrpcOpts() error

type ClientOptions

type ClientOptions struct {
	// contains filtered or unexported fields

func NewDefaultClientOptions

func NewDefaultClientOptions(endpoint, serverName string) *ClientOptions

type GenerateClientFunc

type GenerateClientFunc[T any] func(grpc.ClientConnInterface) T

type Option

type Option func(o *ClientOptions)

func WithClientBalancer

func WithClientBalancer(b registry.Balancer) Option

WithClientBalancer 设置负载均衡

func WithClientDialOption

func WithClientDialOption(opts ...grpc.DialOption) Option

WithClientDialOption 设置 grpc 的 dial 选项

func WithClientDiscovery

func WithClientDiscovery(d registry.Discovery) Option

WithClientDiscovery 设置服务发现

func WithClientEnableMetrics

func WithClientEnableMetrics(enable bool) Option

WithClientEnableMetrics 设置是否开启 普罗米修斯 监控

func WithClientEnableTracing

func WithClientEnableTracing(enable bool) Option

WithClientEnableTracing 设置是否开启链路追踪

func WithClientEndpoint

func WithClientEndpoint(endpoint string) Option

WithClientEndpoint 设置地址

func WithClientInsecure

func WithClientInsecure(enable bool) Option

WithClientInsecure 设置是否安全连接

func WithClientResolver

func WithClientResolver(r registry.Resolver) Option

WithClientResolver 设置服务解析

func WithClientStreamInterceptor

func WithClientStreamInterceptor(in ...grpc.StreamClientInterceptor) Option

WithClientStreamInterceptor 设置 stream 拦截器

func WithClientTLSConfig

func WithClientTLSConfig(c *tls.Config) Option

WithClientTLSConfig with tls config.

func WithClientTimeout

func WithClientTimeout(timeout time.Duration) Option

WithClientTimeout 设置超时时间

func WithClientUnaryInterceptor

func WithClientUnaryInterceptor(in ...grpc.UnaryClientInterceptor) Option

WithClientUnaryInterceptor 设置 一元拦截器

type Server

type Server struct {
	// contains filtered or unexported fields

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Address

func (s *Server) Address() string

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

Endpoint return a real address to registry endpoint. examples:


func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start 启动 grpc 的服务

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type ServerOption

type ServerOption func(o *Server)

func AddServerOption

func AddServerOption(opts ...grpc.ServerOption) ServerOption

func AddServerUnaryInterceptor

func AddServerUnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption

func AddStreamInterceptor

func AddStreamInterceptor(in ...grpc.StreamServerInterceptor) ServerOption

func WithAddress

func WithAddress(address string) ServerOption

func WithHealthCheck

func WithHealthCheck(healthCheck bool) ServerOption

WithHealthCheck 设置是否开启健康检查

func WithListener

func WithListener(lis net.Listener) ServerOption

func WithServerEnableTracing

func WithServerEnableTracing(enableTracing bool) ServerOption

func WithServerMetrics

func WithServerMetrics(metric bool) ServerOption

WithServerMetrics 设置是否开启 普罗米修斯 监控

func WithServerOption

func WithServerOption(opts ...grpc.ServerOption) ServerOption

func WithServerTimeout

func WithServerTimeout(timeout time.Duration) ServerOption

func WithServerUnaryInterceptor

func WithServerUnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption

func WithStreamInterceptor

func WithStreamInterceptor(in ...grpc.StreamServerInterceptor) ServerOption

func WithTLSConfig

func WithTLSConfig(c *tls.Config) ServerOption


Path Synopsis

Jump to

Keyboard shortcuts

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