Documentation
¶
Index ¶
- Variables
- type Client
- type ClientOption
- func ClientAppendStreamInterceptors(interceptor grpc.StreamClientInterceptor) ClientOption
- func ClientAppendUnaryInterceptors(interceptor grpc.UnaryClientInterceptor) ClientOption
- func WithCallTimeout(callTimeout time.Duration) ClientOption
- func WithClientConns(lst []string) ClientOption
- func WithClientPoolCapacity(num int) ClientOption
- func WithClientPoolIdle(second int) ClientOption
- func WithClientPoolInitNum(num int) ClientOption
- func WithDialOptions(opts ...grpc.DialOption) ClientOption
- func WithMaxConcurrentCalls(maxCalls int) ClientOption
- type ClientParm
- type RegistHandler
- type Server
- type ServerOption
- func ServerAppendStreamInterceptors(interceptor grpc.StreamServerInterceptor) ServerOption
- func ServerAppendUnaryInterceptors(interceptor grpc.UnaryServerInterceptor) ServerOption
- func ServerRegisterHandler(handler RegistHandler) ServerOption
- func WithServerGracefulStop() ServerOption
- func WithServerListen(address string) ServerOption
- type ServerParm
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrServiceNotAvailable 服务不可用,通常是因为没有查询到中心节点(coordinate) ErrServiceNotAvailable = errors.New("caller service not available") // ErrConfigConvert 配置转换失败 ErrConfigConvert = errors.New("convert linker config") // ErrCantFindNode 在注册中心找不到对应的服务节点 ErrCantFindNode = errors.New("can't find service node in center") )
View Source
var ( DefaultClientParm = ClientParm{ PoolInitNum: 8, PoolCapacity: 64, MaxConcurrentCalls: 1024, CallTimeout: time.Second * 10, PoolIdle: time.Second * 100, } )
View Source
var ( errors.New("service not registered") )ErrServiceUnavailiable =
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 调用器
func BuildClientWithOption ¶
func BuildClientWithOption(opts ...ClientOption) *Client
type ClientOption ¶
type ClientOption func(*ClientParm)
Option config wraps
func ClientAppendStreamInterceptors ¶
func ClientAppendStreamInterceptors(interceptor grpc.StreamClientInterceptor) ClientOption
func ClientAppendUnaryInterceptors ¶
func ClientAppendUnaryInterceptors(interceptor grpc.UnaryClientInterceptor) ClientOption
func WithCallTimeout ¶
func WithCallTimeout(callTimeout time.Duration) ClientOption
func WithClientConns ¶
func WithClientConns(lst []string) ClientOption
WithClientConns 目标服务器列表地址(静态绑定
func WithClientPoolCapacity ¶
func WithClientPoolCapacity(num int) ClientOption
WithPoolCapacity 连接池的容量大小
func WithClientPoolInitNum ¶
func WithClientPoolInitNum(num int) ClientOption
WithPoolInitNum 连接池初始化数量
func WithDialOptions ¶
func WithDialOptions(opts ...grpc.DialOption) ClientOption
func WithMaxConcurrentCalls ¶
func WithMaxConcurrentCalls(maxCalls int) ClientOption
type ClientParm ¶
type ClientParm struct { PoolInitNum int PoolCapacity int PoolIdle time.Duration MaxConcurrentCalls int CallTimeout time.Duration AddressLst []string UnaryInterceptors []grpc.UnaryClientInterceptor StreamInterceptors []grpc.StreamClientInterceptor // contains filtered or unexported fields }
Parm 调用器配置项
type RegistHandler ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server RPC 服务端
func BuildServerWithOption ¶
func BuildServerWithOption(opts ...ServerOption) *Server
type ServerOption ¶
type ServerOption func(*ServerParm)
Option config wraps
func ServerAppendStreamInterceptors ¶
func ServerAppendStreamInterceptors(interceptor grpc.StreamServerInterceptor) ServerOption
func ServerAppendUnaryInterceptors ¶
func ServerAppendUnaryInterceptors(interceptor grpc.UnaryServerInterceptor) ServerOption
func ServerRegisterHandler ¶
func ServerRegisterHandler(handler RegistHandler) ServerOption
func WithServerGracefulStop ¶
func WithServerGracefulStop() ServerOption
type ServerParm ¶
type ServerParm struct { ListenAddr string UnaryInterceptors []grpc.UnaryServerInterceptor StreamInterceptors []grpc.StreamServerInterceptor Handler RegistHandler GracefulStop bool }
Parm Service 配置
Click to show internal directories.
Click to hide internal directories.