Documentation
¶
Index ¶
- func WithStreamClientInterceptors(interceptors ...grpc.StreamClientInterceptor) grpc.DialOption
- func WithStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption
- func WithUnaryClientInterceptors(interceptors ...grpc.UnaryClientInterceptor) grpc.DialOption
- func WithUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption
- type Client
- type ClientConfig
- type ClientOption
- type ClientOptions
- type DirectClient
- type RegisterFn
- type RpcServer
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithStreamClientInterceptors ¶
func WithStreamClientInterceptors(interceptors ...grpc.StreamClientInterceptor) grpc.DialOption
func WithStreamServerInterceptors ¶ added in v1.4.1
func WithStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption
func WithUnaryClientInterceptors ¶
func WithUnaryClientInterceptors(interceptors ...grpc.UnaryClientInterceptor) grpc.DialOption
func WithUnaryServerInterceptors ¶ added in v1.4.1
func WithUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption
Types ¶
type Client ¶
type Client interface {
Next() (*grpc.ClientConn, bool)
}
type ClientConfig ¶ added in v1.4.1
type ClientConfig struct { Host string Name []string Timeout string MaxAttempts string InitialBackoff string MaxBackoff string BackoffMultiplier string RetryableStatusCodes []string WaitForReady string MaxTokens string TokenRatio string DialOptions []grpc.DialOption }
func (*ClientConfig) WithDefaultServiceConfig ¶ added in v1.4.1
func (clientConfig *ClientConfig) WithDefaultServiceConfig() grpc.DialOption
grpc 重试策略:重试、对冲 最多执行4次 RPC 请求,一个原始请求,三个重试请求,并且只有状态码为 `UNAVAILABLE` 时才重试 MaxAttempts 最大尝试次数 InitialBackoff 第一次重试的时间间隔 MaxBackoff 第 n 次的重试间隔 BackoffMultiplier 用于计算 MaxBackoff,必须大于0 RetryableStatusCodes 匹配返回的状态码,从而进行重试
type ClientOption ¶
type ClientOption func(options *ClientOptions)
func WithDialOption ¶
func WithDialOption(opt grpc.DialOption) ClientOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
type ClientOptions ¶
type ClientOptions struct { Timeout time.Duration DialOptions []grpc.DialOption }
type DirectClient ¶
type DirectClient struct {
// contains filtered or unexported fields
}
func NewDirectClient ¶
func NewDirectClient(host string, timeout int64, opts ...ClientOption) (*DirectClient, error)
@desc 初始化客户端 timeout:单位毫秒,默认两秒超时 @auth liuguoqiang 2020-04-21 @param @return
func NewDirectClientV2 ¶ added in v1.4.1
func NewDirectClientV2(clientConfig *ClientConfig) (*DirectClient, error)
@desc 初始化客户端 @auth liuguoqiang 2020-04-21 @param @return
func (*DirectClient) Next ¶
func (c *DirectClient) Next() (*grpc.ClientConn, bool)
@desc 返回grpc链接 @auth liuguoqiang 2020-04-21 @param @return
type RegisterFn ¶ added in v1.4.1
type RpcServer ¶ added in v1.4.1
type RpcServer struct {
// contains filtered or unexported fields
}
func NewRpcServer ¶ added in v1.4.1
func NewRpcServer(listenOn string, timeout int64, register RegisterFn) (*RpcServer, error)
@desc rpc服务端初始化入口函数 @auth liuguoqiang 2020-06-11 @param @return
func (RpcServer) AddOptions ¶ added in v1.4.1
func (s RpcServer) AddOptions(options ...grpc.ServerOption)
func (RpcServer) AddStreamInterceptors ¶ added in v1.4.1
func (s RpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
func (RpcServer) AddUnaryInterceptors ¶ added in v1.4.1
func (s RpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
type Server ¶ added in v1.4.1
type Server interface { AddOptions(options ...grpc.ServerOption) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) Start(register RegisterFn) error }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.