Documentation
¶
Index ¶
- func SetWriteTimeout(d time.Duration)
- type BasicConnHandler
- func (x *BasicConnHandler) AddExitHook(hook ConnExitEvent)
- func (x *BasicConnHandler) AddStartHook(hook ConnStartEvent)
- func (x *BasicConnHandler) ExitHooks() []ConnExitEvent
- func (x *BasicConnHandler) MetaInfo() MetaInfo
- func (x *BasicConnHandler) Send(bs []byte, timeout time.Duration) error
- func (x *BasicConnHandler) SetMetaInfo(m MetaInfo)
- func (x *BasicConnHandler) StartHooks() []ConnStartEvent
- type BasicMetaInfo
- type BasicServer
- type CommServerCnf
- type CommonConnHandler
- type CommonIncomingHook
- type CommonServer
- type ConnExitEvent
- type ConnHandlerGenerator
- type ConnHandlerRunner
- type ConnStartEvent
- type IConnHandler
- type ITemporary
- type MetaInfo
- type ServerAcceptCnf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetWriteTimeout ¶ added in v1.2.12
Types ¶
type BasicConnHandler ¶ added in v1.2.13
type BasicConnHandler struct {
// connection
Conn net.Conn
// contains filtered or unexported fields
}
BasicConnHandler basic connection handler
func NewBasicConnHandler ¶ added in v1.2.13
func NewBasicConnHandler(conn net.Conn) *BasicConnHandler
NewBasicConnHandler : new basic connection handler
func (*BasicConnHandler) AddExitHook ¶ added in v1.2.13
func (x *BasicConnHandler) AddExitHook(hook ConnExitEvent)
AddExitHook add exit hook
func (*BasicConnHandler) AddStartHook ¶ added in v1.2.13
func (x *BasicConnHandler) AddStartHook(hook ConnStartEvent)
AddStartHook add start hook
func (*BasicConnHandler) ExitHooks ¶ added in v1.2.13
func (x *BasicConnHandler) ExitHooks() []ConnExitEvent
ExitHooks get exit hooks
func (*BasicConnHandler) MetaInfo ¶ added in v1.2.13
func (x *BasicConnHandler) MetaInfo() MetaInfo
MetaInfo get meta info
func (*BasicConnHandler) Send ¶ added in v1.2.13
func (x *BasicConnHandler) Send(bs []byte, timeout time.Duration) error
Send bytes to connection with timeout
func (*BasicConnHandler) SetMetaInfo ¶ added in v1.2.13
func (x *BasicConnHandler) SetMetaInfo(m MetaInfo)
SetMetaInfo set meta info
func (*BasicConnHandler) StartHooks ¶ added in v1.2.13
func (x *BasicConnHandler) StartHooks() []ConnStartEvent
StartHooks get start hooks
type BasicMetaInfo ¶ added in v1.2.12
type BasicMetaInfo struct {
RemoteAddr string
}
BasicMetaInfo basic meta info
func (*BasicMetaInfo) MarshalLogObject ¶ added in v1.2.12
func (m *BasicMetaInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error
type BasicServer ¶ added in v1.2.13
type BasicServer struct {
// contains filtered or unexported fields
}
BasicServer : basic tcp server frame
func NewBasicServer ¶ added in v1.2.13
func NewBasicServer(cnf *ServerAcceptCnf, gen ConnHandlerGenerator) *BasicServer
NewBasicServer :
func (*BasicServer) ConnectionCount ¶ added in v1.2.13
func (x *BasicServer) ConnectionCount() int32
ConnectionCount :
func (*BasicServer) SetExitHook ¶ added in v1.2.15
func (x *BasicServer) SetExitHook(hook ConnExitEvent)
SetExitHook : set exit hook
func (*BasicServer) SetStartHook ¶ added in v1.2.15
func (x *BasicServer) SetStartHook(hook ConnStartEvent)
SetStartHook : set start hook
type CommServerCnf ¶ added in v1.2.13
type CommServerCnf struct {
*ServerAcceptCnf
MaxSendQSize int `json:"maxSendQSize"`
}
CommServerCnf common server config
func DefaultCommServerCnf ¶ added in v1.2.13
func DefaultCommServerCnf() *CommServerCnf
DefaultCommServerCnf : get default common server cnf
type CommonConnHandler ¶ added in v1.2.13
type CommonConnHandler struct {
*BasicConnHandler
// contains filtered or unexported fields
}
CommonConnHandler connection handler
func NewCommonConnHandler ¶ added in v1.2.13
func NewCommonConnHandler(conn net.Conn, qSize int, incomingHook CommonIncomingHook) *CommonConnHandler
NewCommonConnHandler : new connection handler
func (*CommonConnHandler) CLose ¶ added in v1.2.13
func (x *CommonConnHandler) CLose()
CLose : close connection
func (*CommonConnHandler) LoopReceive ¶ added in v1.2.13
func (x *CommonConnHandler) LoopReceive()
LoopReceive : loop receive
func (*CommonConnHandler) LoopSend ¶ added in v1.2.13
func (x *CommonConnHandler) LoopSend()
LoopSend : loop to send bytes
func (*CommonConnHandler) SendAsync ¶ added in v1.2.13
func (x *CommonConnHandler) SendAsync(bs []byte) error
SendAsync send bytes async
type CommonIncomingHook ¶ added in v1.2.13
type CommonIncomingHook func(handler *CommonConnHandler, conn net.Conn, metaInfo MetaInfo) error
CommonIncomingHook incoming hook function
type CommonServer ¶ added in v1.2.13
type CommonServer struct {
*BasicServer
// contains filtered or unexported fields
}
CommonServer : common tcp server frame
func NewCommonTCPSrv ¶ added in v1.2.13
func NewCommonTCPSrv(cnf *CommServerCnf, incomingHook CommonIncomingHook) *CommonServer
NewCommonTCPSrv : new common tcp server
func (*CommonServer) Close ¶ added in v1.2.13
func (s *CommonServer) Close() error
Close : close server
func (*CommonServer) Run ¶ added in v1.2.13
func (s *CommonServer) Run(errChan chan<- error)
Run : loop start server errChan : a channel to receive error cnf : server start config
func (*CommonServer) Start ¶ added in v1.2.13
func (s *CommonServer) Start() error
Start : loop start server with config
type ConnExitEvent ¶ added in v1.2.12
ConnExitEvent on connection exit
type ConnHandlerGenerator ¶ added in v1.2.13
type ConnHandlerGenerator func(conn net.Conn) IConnHandler
ConnHandlerGenerator connection handler generator
type ConnHandlerRunner ¶ added in v1.2.13
type ConnHandlerRunner struct {
IConnHandler
// contains filtered or unexported fields
}
ConnHandlerRunner connection handler runner
func NewConnHandlerRunner ¶ added in v1.2.13
func NewConnHandlerRunner(handler IConnHandler) *ConnHandlerRunner
NewConnHandlerRunner : new connection handler runner
func (*ConnHandlerRunner) Start ¶ added in v1.2.13
func (x *ConnHandlerRunner) Start()
Start : start connection handler
type ConnStartEvent ¶ added in v1.2.12
type ConnStartEvent func(metaInfo MetaInfo)
ConnStartEvent on connection start
type IConnHandler ¶ added in v1.2.13
type IConnHandler interface {
// AddStartHook add start hook
AddStartHook(hook ConnStartEvent)
// AddExitHook add exit hook
AddExitHook(hook ConnExitEvent)
// LoopReceive : loop receive
LoopReceive()
// LoopSend : loop to send bytes
LoopSend()
// SetMetaInfo set meta info
SetMetaInfo(m MetaInfo)
// MetaInfo get meta info
MetaInfo() MetaInfo
// StartHooks get start hooks
StartHooks() []ConnStartEvent
// ExitHooks get exit hooks
ExitHooks() []ConnExitEvent
}
IConnHandler connection handler interface
type ITemporary ¶ added in v1.1.8
type ITemporary interface {
Temporary() bool
}
ITemporary interface to replace net.Error interface to avoid go lint check
type MetaInfo ¶ added in v1.2.12
type MetaInfo interface {
zapcore.ObjectMarshaler
}
MetaInfo meta info for logging
type ServerAcceptCnf ¶ added in v1.2.12
type ServerAcceptCnf struct {
Address string `json:"address"`
AcceptDelay timex.Duration `json:"acceptDelay"`
AcceptMaxDelay timex.Duration `json:"acceptMaxDelay"`
AcceptMaxRetry int `json:"acceptMaxRetry"`
MaxConn int32 `json:"maxConn"`
}
ServerAcceptCnf server start config
func DefaultServerAcceptCnf ¶ added in v1.2.12
func DefaultServerAcceptCnf() *ServerAcceptCnf
DefaultServerAcceptCnf : get default start cnf