Documentation ¶
Index ¶
- Constants
- Variables
- func GetLogger() logger
- func SetLogger(l logger)
- func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- type Conn
- func (c *Conn) Close()
- func (c *Conn) CloseRead() error
- func (c *Conn) GetAddr() string
- func (c *Conn) GetBuffer() *codec.Buffer
- func (c *Conn) GetData() interface{}
- func (c *Conn) GetFd() int32
- func (c *Conn) SetData(data interface{})
- func (c *Conn) Write(bytes []byte) (int, error)
- func (c *Conn) WriteWithEncoder(bytes []byte) error
- type Handler
- type Option
- type Server
Constants ¶
View Source
const ( EpollRead = syscall.EPOLLIN | syscall.EPOLLPRI | syscall.EPOLLERR | syscall.EPOLLHUP | unix.EPOLLET | syscall.EPOLLRDHUP EpollClose = uint32(syscall.EPOLLIN | syscall.EPOLLRDHUP) )
对端关闭连接 8193
View Source
const ( EventIn = 1 // 数据流入 EventClose = 2 // 断开连接 EventTimeout = 3 // 检测到超时 )
Variables ¶
View Source
var (
ErrReadTimeout = errors.New("tcp read timeout")
)
Functions ¶
func TimeEncoder ¶
func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn 客户端长连接
func (*Conn) WriteWithEncoder ¶ added in v1.10.0
WriteWithEncoder 使用编码器写入
type Handler ¶
type Handler interface { OnConnect(c *Conn) // OnConnect 当TCP长连接建立成功是回调 OnMessage(c *Conn, bytes []byte) // OnMessage 当客户端有数据写入是回调 OnClose(c *Conn, err error) // OnClose 当客户端主动断开链接或者超时时回调,err返回关闭的原因 }
Handler Server 注册接口
type Option ¶ added in v1.1.0
type Option interface {
// contains filtered or unexported methods
}
func WithAcceptGNum ¶ added in v1.1.0
WithAcceptGNum 设置建立连接的goroutine数量
func WithDecoder ¶ added in v1.10.0
WithDecoder 设置解码器
func WithEncoder ¶ added in v1.10.0
WithEncoder 设置解码器
func WithIOEventQueueLen ¶ added in v1.2.1
WithIOEventQueueLen 设置IO事件队列长度,默认值是1024
func WithReadBufferLen ¶ added in v1.5.0
WithReadBufferLen 设置缓存区大小
func WithTimeout ¶ added in v1.1.0
WithTimeout 设置TCP超时检查的间隔时间以及超时时间
Source Files ¶
Click to show internal directories.
Click to hide internal directories.