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 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
- 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.0
func WithStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption
func WithUnaryClientInterceptors ¶
func WithUnaryClientInterceptors(interceptors ...grpc.UnaryClientInterceptor) grpc.DialOption
func WithUnaryServerInterceptors ¶ added in v1.4.0
func WithUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption
Types ¶
type Client ¶
type Client interface {
Next() (*grpc.ClientConn, bool)
}
type ClientConfig ¶ added in v1.4.6
type ClientConfig struct { Host string //RPC链接 Name []string //RPC包名.服务名 如shop_base.ShopBase 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链接可选参数 }
func NewClientConfig ¶ added in v1.4.6
func NewClientConfig(host string, name []string) (*ClientConfig, error)
@desc RPC客户端初始化链接配置 @auth liuguoqiang 2020-08-12 @param @return
func (*ClientConfig) WithDefaultServiceConfig ¶ added in v1.4.6
func (clientConfig *ClientConfig) WithDefaultServiceConfig() grpc.DialOption
@desc 设置默认配置 @auth liuguoqiang 2020-08-12 @param @return
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
}
Deprecated
func NewDirectClient ¶
func NewDirectClient(host string, timeout int64, opts ...ClientOption) (*DirectClient, error)
Deprecated 推荐使用 NewGrpcClient @desc 初始化客户端 timeout:单位毫秒,默认两秒超时 @auth liuguoqiang 2020-04-21 @param @return
func NewDirectClientV2 ¶ added in v1.4.6
func NewDirectClientV2(clientConfig *ClientConfig) (*DirectClient, error)
Deprecated 推荐使用 NewGrpcClient @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 GrpcClient ¶ added in v1.5.5
type GrpcClient struct { Name string ClientConn *grpc.ClientConn // contains filtered or unexported fields }
func NewGrpcClient ¶ added in v1.5.5
func NewGrpcClient(name, addr string, cfg *GrpcClientConfig) (gc *GrpcClient, err error)
NewGrpcClient new grpc client
func (*GrpcClient) Close ¶ added in v1.5.6
func (c *GrpcClient) Close()
func (*GrpcClient) Conn ¶ added in v1.5.5
func (c *GrpcClient) Conn() (conn *grpc.ClientConn, ok bool)
Conn get ready *grpc.ClientConn
type GrpcClientConfig ¶ added in v1.5.5
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 ¶ added in v1.5.5
type GrpcServer struct { Name string // contains filtered or unexported fields }
func NewGrpcServer ¶ added in v1.5.5
func NewGrpcServer(name, addr string, cfg *GrpcServerConfig) *GrpcServer
NewGrpcServer new grpc server
func (*GrpcServer) AddOptions ¶ added in v1.5.5
func (s *GrpcServer) AddOptions(options ...grpc.ServerOption)
func (*GrpcServer) AddStreamInterceptors ¶ added in v1.5.5
func (s *GrpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
func (*GrpcServer) AddUnaryInterceptors ¶ added in v1.5.5
func (s *GrpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
func (*GrpcServer) Close ¶ added in v1.5.6
func (s *GrpcServer) Close()
func (*GrpcServer) RegisterService ¶ added in v1.5.5
func (s *GrpcServer) RegisterService(register RegisterFn) *GrpcServer
RegisterService .Start() 之前,必须先处理此方法
type GrpcServerConfig ¶ added in v1.5.5
type GrpcServerConfig struct { // 超时时间,单位:ms Timeout int }
type RegisterFn ¶ added in v1.4.0
type RpcServer ¶ added in v1.4.0
type RpcServer struct {
// contains filtered or unexported fields
}
Deprecated
func NewRpcServer ¶ added in v1.4.0
func NewRpcServer(name, addr string, timeout int64, register RegisterFn) *RpcServer
Deprecated 推荐使用 NewGrpcServer @desc rpc服务端初始化入口函数 @auth liuguoqiang 2020-06-11 @param timeout 为0时,不做超时处理 @return
func (RpcServer) AddOptions ¶ added in v1.4.0
func (s RpcServer) AddOptions(options ...grpc.ServerOption)
func (RpcServer) AddStreamInterceptors ¶ added in v1.4.0
func (s RpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
func (RpcServer) AddUnaryInterceptors ¶ added in v1.4.0
func (s RpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
type Server ¶ added in v1.4.0
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.