Documentation ¶
Index ¶
- type GrpcClient
- type GrpcClientConfig
- type GrpcServer
- func (s *GrpcServer) AddOptions(options ...grpc.ServerOption)
- func (s *GrpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
- func (s *GrpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
- func (s *GrpcServer) Close()
- func (s *GrpcServer) RegisterService(register RegisterFn) *GrpcServer
- func (s *GrpcServer) Start()
- type GrpcServerConfig
- type RegisterFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GrpcClient ¶
type GrpcClient struct { Name string ClientConn *grpc.ClientConn // contains filtered or unexported fields }
func NewGrpcClient ¶
func NewGrpcClient(name, addr string, cfg *GrpcClientConfig) (gc *GrpcClient, err error)
NewGrpcClient new grpc client
func (*GrpcClient) Close ¶
func (c *GrpcClient) Close()
type GrpcClientConfig ¶
type GrpcClientConfig struct { Name []string Timeout string //超时时间,默认:5s MaxAttempts string //最大重试次数,必须是大于 1 的整数,对于大于5的值会被视为5,默认:4 InitialBackoff string //第一次重试默认时间间隔,必须具有大于0,默认:2s MaxBackoff string //最大重试时间间隔,必须具有大于0,默认:3s BackoffMultiplier string //间隔增量乘数因子,大于零,默认:1 RetryableStatusCodes []string //重试会根据请求返回的状态码是否符合 retryableStatusCodes来进行重试请求,默认:UNAVAILABLE WaitForReady string //如果为false,则RPC将在连接到服务器的瞬间失败时立即中止。否则,gRPC会尝试连接,直到超过截止日期。默认:true MaxTokens string //如果 token_count <= ( maxTokens / 2), 则关闭重试策略,直到 token_count > (maxTokens/2),恢复重试,默认10 TokenRatio string //成功 RPC 将会递增 token_count * tokenRatio DialOptions []grpc.DialOption //RPC链接可选参数 }
type GrpcServer ¶
type GrpcServer struct { Name string // contains filtered or unexported fields }
func NewGrpcServer ¶
func NewGrpcServer(name, addr string, cfg *GrpcServerConfig) *GrpcServer
NewGrpcServer new grpc server
func (*GrpcServer) AddOptions ¶
func (s *GrpcServer) AddOptions(options ...grpc.ServerOption)
func (*GrpcServer) AddStreamInterceptors ¶
func (s *GrpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
func (*GrpcServer) AddUnaryInterceptors ¶
func (s *GrpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
func (*GrpcServer) Close ¶
func (s *GrpcServer) Close()
func (*GrpcServer) RegisterService ¶
func (s *GrpcServer) RegisterService(register RegisterFn) *GrpcServer
RegisterService .Start() 之前,必须先处理此方法
type GrpcServerConfig ¶
type RegisterFn ¶
Click to show internal directories.
Click to hide internal directories.