Documentation
¶
Index ¶
- func SetWriteTimeout(d time.Duration)
- type BasicMetaInfo
- type ConnExitEvent
- type ConnHandler
- func NewConnHandler(conn net.Conn, qSize int, incomingHook IncomingHook) *ConnHandler
- func NewConnHandlerV2(conn net.Conn, qSize int, incomingHook IncomingHook, exitHook ConnExitEvent) *ConnHandler
- func NewConnHandlerV3(conn net.Conn, qSize int, incomingHook IncomingHook, startHook ConnStartEvent, ...) *ConnHandler
- type ConnStartEvent
- type ITemporary
- type IncomingHook
- type MetaInfo
- type Option
- type Server
- func (s *Server) Address() string
- func (s *Server) Close() error
- func (s *Server) ConnectionCount() int32
- func (s *Server) LoopStart(opts ...Option) error
- func (s *Server) LoopStartX(cnf *ServerAcceptCnf) error
- func (s *Server) RunWithCnf(errChan chan<- error, cnf *ServerAcceptCnf)
- func (s *Server) RunWithOption(errChan chan<- error, opts ...Option)
- type ServerAcceptCnf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetWriteTimeout ¶ added in v1.2.12
Types ¶
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 ConnExitEvent ¶ added in v1.2.12
ConnExitEvent on connection exit
type ConnHandler ¶ added in v1.2.12
type ConnHandler struct {
// contains filtered or unexported fields
}
ConnHandler connection handler
func NewConnHandler ¶ added in v1.2.12
func NewConnHandler(conn net.Conn, qSize int, incomingHook IncomingHook) *ConnHandler
NewConnHandler : new connection handler
func NewConnHandlerV2 ¶ added in v1.2.12
func NewConnHandlerV2(conn net.Conn, qSize int, incomingHook IncomingHook, exitHook ConnExitEvent) *ConnHandler
NewConnHandlerV2 : new connection handler with exit hooks
func NewConnHandlerV3 ¶ added in v1.2.12
func NewConnHandlerV3(conn net.Conn, qSize int, incomingHook IncomingHook, startHook ConnStartEvent, exitHook ConnExitEvent) *ConnHandler
NewConnHandlerV3 : new connection handler with start and exit hooks
func (*ConnHandler) AddExitHook ¶ added in v1.2.12
func (x *ConnHandler) AddExitHook(hook ConnExitEvent)
AddExitHook add exit hook
func (*ConnHandler) AddStartHook ¶ added in v1.2.12
func (x *ConnHandler) AddStartHook(hook ConnStartEvent)
AddStartHook add start hook
func (*ConnHandler) SendAsync ¶ added in v1.2.12
func (x *ConnHandler) SendAsync(bs []byte) error
SendAsync send bytes async
func (*ConnHandler) SetMetaInfo ¶ added in v1.2.12
func (x *ConnHandler) SetMetaInfo(m MetaInfo)
SetMetaInfo set meta info
func (*ConnHandler) Start ¶ added in v1.2.12
func (x *ConnHandler) Start()
Start : start connection handler
type ConnStartEvent ¶ added in v1.2.12
type ConnStartEvent func(metaInfo MetaInfo)
ConnStartEvent on connection start
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 IncomingHook ¶ added in v1.2.12
type IncomingHook func(handler *ConnHandler, conn net.Conn, metaInfo MetaInfo) error
IncomingHook incoming hook function
type MetaInfo ¶ added in v1.2.12
type MetaInfo interface {
zapcore.ObjectMarshaler
}
MetaInfo meta info for logging
type Option ¶
type Option func(o *ServerAcceptCnf)
Option server start option
func WithAccMaxDelay ¶
WithAccMaxDelay : setup acceptMaxDelay
func WithMaxSendQSize ¶ added in v1.2.12
WithMaxSendQSize : setup max send queue size
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server : tcp server frame
func (*Server) ConnectionCount ¶ added in v1.2.12
ConnectionCount :
func (*Server) LoopStartX ¶ added in v1.2.12
func (s *Server) LoopStartX(cnf *ServerAcceptCnf) error
LoopStartX : loop start server with config
func (*Server) RunWithCnf ¶ added in v1.2.12
func (s *Server) RunWithCnf(errChan chan<- error, cnf *ServerAcceptCnf)
RunWithCnf : loop start server with config errChan : a channel to receive error cnf : server start config
func (*Server) RunWithOption ¶ added in v1.2.12
RunWithOption : loop start server errChan : a channel to receive error opts : server start options
type ServerAcceptCnf ¶ added in v1.2.12
type ServerAcceptCnf struct {
AcceptDelay time.Duration `json:"acceptDelay"`
AcceptMaxDelay time.Duration `json:"acceptMaxDelay"`
AcceptMaxRetry int `json:"acceptMaxRetry"`
MaxSendQSize int `json:"maxSendQSize"`
MaxConn int32 `json:"maxConn"`
}
ServerAcceptCnf server start config
func DefaultServerAcceptCnf ¶ added in v1.2.12
func DefaultServerAcceptCnf() *ServerAcceptCnf
DefaultServerAcceptCnf : get default start cnf