Versions in this module Expand all Collapse all v1 v1.8.3 Dec 1, 2021 Changes in this version + const EpollClose — linux/amd64 + const EpollRead — linux/amd64 + const EventClose + const EventIn + const EventTimeout + var ErrNotEnough = errors.New("not enough") + var ErrReadTimeout = errors.New("tcp read timeout") + func GetLogger() logger + func NewHeaderLenEncoder(headerLen, writeBufferLen int) *headerLenEncoder + func SetLogger(l logger) + func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) + type Buffer struct + func NewBuffer(bytes []byte) *Buffer + func (b *Buffer) Cap() int + func (b *Buffer) GetBuf() []byte + func (b *Buffer) Len() int + func (b *Buffer) Read(offset, limit int) ([]byte, error) + func (b *Buffer) ReadFromFD(fd int) error + func (b *Buffer) ReadFromReader(reader io.Reader) (int, error) + func (b *Buffer) Seek(len int) ([]byte, error) + type Conn struct + func (c *Conn) Close() error + func (c *Conn) CloseRead() error + func (c *Conn) GetAddr() string + func (c *Conn) GetBuffer() *Buffer + func (c *Conn) GetData() interface{} + func (c *Conn) GetFd() int32 + func (c *Conn) Read() error + func (c *Conn) SetData(data interface{}) + func (c *Conn) Write(bytes []byte) (int, error) + type Decoder interface + Decode func(c *Conn) error + func NewHeaderLenDecoder(headerLen int) Decoder + type Encoder interface + EncodeToFD func(fd int32, bytes []byte) error + type Handler interface + OnClose func(c *Conn, err error) + OnConnect func(c *Conn) + OnMessage func(c *Conn, bytes []byte) + type Option interface + func WithAcceptGNum(num int) Option + func WithIOEventQueueLen(num int) Option + func WithIOGNum(num int) Option + func WithReadBufferLen(len int) Option + func WithTimeout(timeoutTicker, timeout time.Duration) Option + type Server struct + func NewServer(address string, handler Handler, decoder Decoder, opts ...Option) (*Server, error) + func (s *Server) GetConn(fd int32) (*Conn, bool) + func (s *Server) GetConnsNum() int64 + func (s *Server) Run() + func (s *Server) Stop()