Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶
type Bootstrap interface { //NewServer 创建一个新的Server NewServer(netType, host string) Server //NewClient 创建一个信的Client NewClient(netType, host string) Client //Close 关闭多有的链接 Close() error }
Bootstrap 启动接口
func NewBootStrap ¶
func NewBootStrap(config *Config, initContextFunc InitConnContextFunc, connectionSetting func(conn net.Conn)) Bootstrap
NewBootStrap 初始化Bootstrap
type Client ¶
type Client interface { GetConnContext() ConnContext Connect(timeout time.Duration) error Close() error }
Client net client interface
type Config ¶
type Config struct { //最大连接数 MaxConnection int `json:"max_connection"` //最大并发处理个数 MaxConcurrentHandler int `json:"max_concurrent_handler"` //是否顺序处理消息,默认false,即可以并发处理消息 SyncHandler bool `json:"sync_handler"` }
Config net config
type ConnContext ¶
type ConnContext interface { GetID() int64 AddListen(name string, listen ContextListen) error RemoveListen(name string) GetListens() map[string]ContextListen RemoteAddr() net.Addr LocalAddr() net.Addr IsOpen() bool SetHandler(handler Handler) SetProtocols(protocols ...Protocol) Start(cxt context.Context) Close(cxt context.Context) error Write(cxt context.Context, data interface{}) FireException(cxt context.Context, err error) }
ConnContext 建立建立后的上下文
type ContextListen ¶
type ContextListen interface { OnActive(context.Context, ConnContext) OnClose(context.Context, ConnContext) OnException(context.Context, ConnContext, error) }
ContextListen listen
type Handler ¶
type Handler interface { Active(cxt context.Context, context ConnContext) Exception(cxt context.Context, connContext ConnContext, err error) Read(cxt context.Context, connContext ConnContext, data interface{}) Close(context.Context, ConnContext) }
Handler 处理器接口
type InitConnContextFunc ¶
type InitConnContextFunc func(cxt context.Context, connContext ConnContext)
InitConnContextFunc init connContext
type Protocol ¶
type Protocol interface { //用于激活 Protocol 的后台任务 //Start(cxt context.Context, context ConnContext)// TODO 待考虑 //数据编码 Encode(cxt context.Context, context ConnContext, chain ProtocolChain, data interface{}) //数据解码 Decode(cxt context.Context, context ConnContext, chain ProtocolChain, data interface{}) EncodeDestroy() DecodeDestroy() }
Protocol protocol struct
type ProtocolChain ¶
type ProtocolChain interface {
Fire(cxt context.Context, connContext ConnContext, data interface{})
}
ProtocolChain Protocol chain interface
Source Files
¶
Click to show internal directories.
Click to hide internal directories.