Documentation ¶
Index ¶
- func ConsulRegister(conf ServerConfig) (server.Plugin, error)
- func CustomOptions(f func() client.Option)
- func EtcdV3Register(conf ServerConfig) (server.Plugin, error)
- func ZooKeeperRegister(conf ServerConfig) (server.Plugin, error)
- type AuthFunc
- type BalanceModel
- type ClientConfig
- type ClientLoggerPlugin
- type ClientPool
- type FailRetryModel
- type RPCHeader
- func (h *RPCHeader) Bool(ctx context.Context, key string) (bool, error)
- func (h *RPCHeader) BoolDefault(ctx context.Context, key string, def bool) bool
- func (h *RPCHeader) Int(ctx context.Context, key string) (int, error)
- func (h *RPCHeader) Int32(ctx context.Context, key string) (int32, error)
- func (h *RPCHeader) Int32Default(ctx context.Context, key string, def int32) int32
- func (h *RPCHeader) Int64(ctx context.Context, key string) (int64, error)
- func (h *RPCHeader) Int64Default(ctx context.Context, key string, def int64) int64
- func (h *RPCHeader) IntDefault(ctx context.Context, key string, def int) int
- func (h *RPCHeader) Set(ctx context.Context, header map[string]string) context.Context
- func (h *RPCHeader) Value(ctx context.Context, key string) string
- type RegisterPluginType
- type Server
- type ServerConfig
- type ServerLoggerPlugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsulRegister ¶
func ConsulRegister(conf ServerConfig) (server.Plugin, error)
func CustomOptions ¶
func EtcdV3Register ¶
func EtcdV3Register(conf ServerConfig) (server.Plugin, error)
func ZooKeeperRegister ¶
func ZooKeeperRegister(conf ServerConfig) (server.Plugin, error)
Types ¶
type BalanceModel ¶
type BalanceModel int
BalanceModel 负载均衡模式
const ( // Random 随机 Random BalanceModel = iota + 1 // RoundRobin 轮询 RoundRobin // ConsistentHash 一致性哈希 ConsistentHash // NetworkQuality 网络质量 NetworkQuality )
type ClientConfig ¶
type ClientConfig struct { ClientName string BasePath string RegisterPlugin RegisterPluginType RegisterServers []string FailRetryModel FailRetryModel BalanceModel BalanceModel PoolSize int }
type ClientLoggerPlugin ¶
type ClientLoggerPlugin struct { }
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
func NewRPCClient ¶
func NewRPCClient(conf ClientConfig) (c *ClientPool, err error)
type FailRetryModel ¶
type FailRetryModel int
FailRetryModel 失败重试模式
const ( // FailFast 如果调用失败,立即返回错误 FailFast FailRetryModel = iota + 1 // FailOver 如果调用失败,重试其他服务器 FailOver // FailTry 如果调用失败,重试当前服务器 FailTry )
type RPCHeader ¶
type RPCHeader struct { }
func (*RPCHeader) BoolDefault ¶
func (*RPCHeader) Int32Default ¶
func (*RPCHeader) Int64Default ¶
func (*RPCHeader) IntDefault ¶
type RegisterPluginType ¶
type RegisterPluginType string
const ( ETCD RegisterPluginType = "etcd" ZK RegisterPluginType = "zookeeper" Con RegisterPluginType = "consul" )
type Server ¶
type Server struct { Name string // contains filtered or unexported fields }
func NewRPCServer ¶
func NewRPCServer(conf ServerConfig, plugins ...server.Plugin) (rpc *Server, err error)
func (*Server) RegisterAuthFunc ¶
RegisterAuthFunc 注册认证回调
type ServerConfig ¶
type ServerConfig struct { ServerName string Addr string BasePath string RegisterPlugin RegisterPluginType RegisterServers []string Handle interface{} }
type ServerLoggerPlugin ¶
type ServerLoggerPlugin struct { }
func (*ServerLoggerPlugin) PostWriteResponse ¶
func (*ServerLoggerPlugin) PreHandleRequest ¶
Click to show internal directories.
Click to hide internal directories.