Documentation ¶
Index ¶
- type Server
- type TCPServer
- func (s *TCPServer) Close()
- func (s *TCPServer) CountAvailableWorkers() uint32
- func (s *TCPServer) CountBusyWorkers() uint32
- func (s *TCPServer) Run(listen string) (err error)
- func (s *TCPServer) SetAcceptErrorHandler(h func(error))
- func (s *TCPServer) SetHandler(h func(net.Conn))
- func (s *TCPServer) SetRejectHandler(h func(net.Conn, error))
- func (s *TCPServer) SetWorkersPoolSize(n ...uint32)
- type UnixServer
- func (s *UnixServer) Close()
- func (s *UnixServer) CountAvailableWorkers() uint32
- func (s *UnixServer) CountBusyWorkers() uint32
- func (s *UnixServer) Run(file string) (err error)
- func (s *UnixServer) SetAcceptErrorHandler(h func(error))
- func (s *UnixServer) SetHandler(h func(net.Conn))
- func (s *UnixServer) SetRejectHandler(h func(net.Conn, error))
- func (s *UnixServer) SetWorkersPoolSize(n ...uint32)
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server interface { Run(string) error SetHandler(func(net.Conn)) SetRejectHandler(func(net.Conn, error)) SetAcceptErrorHandler(func(error)) SetWorkersPoolSize(...uint32) CountBusyWorkers() uint32 CountAvailableWorkers() uint32 Close() }
Server interface
type TCPServer ¶
type TCPServer struct {
// contains filtered or unexported fields
}
TCPServer struct
func NewTCPServer ¶
NewTCPServer 创建新的TCPServer NewTcpServer(x)表示总共有x个workers,并且全部预先创建好; NewTcpServer(y)表示总共有x个workers,只预先创建y个。
func (*TCPServer) CountAvailableWorkers ¶
func (s *TCPServer) CountAvailableWorkers() uint32
func (*TCPServer) CountBusyWorkers ¶
func (s *TCPServer) CountBusyWorkers() uint32
func (*TCPServer) SetAcceptErrorHandler ¶
func (s *TCPServer) SetAcceptErrorHandler(h func(error))
SetAcceptErrorHandler 当监听失败时的处理方法,此方法在监听协程执行,会阻塞监听 协程,处理完成之前无法监听新的连接。
func (*TCPServer) SetHandler ¶
SetHandler 设置连接建立后的处理方法,此方法会分到不同的Worker去执行,不阻塞 监听协程。
func (*TCPServer) SetRejectHandler ¶
SetRejectHandler 设置当连接数过多被拒绝时的处理方法,此方法在监听协程执 行,会阻塞监听协程,处理完成之前无法监听新的连接。
func (*TCPServer) SetWorkersPoolSize ¶
func (s *TCPServer) SetWorkersPoolSize(n ...uint32)
SetWorkersPoolSize 设置Worker数量 如果调用SetWorkersPoolSize(x)表示总共有x个workers,并且全部预先创建好; 如果调用SetWorkersPoolSize(y, x)表示总共有x个workers,只预先创建y个。
type UnixServer ¶
type UnixServer struct {
// contains filtered or unexported fields
}
UnixServer struct
func NewUnixServer ¶
func NewUnixServer(n ...uint32) *UnixServer
NewUnixServer 创建新的TCPServer NewUnixServer(x)表示总共有x个workers,并且全部预先创建好; NewUnixServer(y)表示总共有x个workers,只预先创建y个。
func (*UnixServer) CountAvailableWorkers ¶
func (s *UnixServer) CountAvailableWorkers() uint32
func (*UnixServer) CountBusyWorkers ¶
func (s *UnixServer) CountBusyWorkers() uint32
func (*UnixServer) SetAcceptErrorHandler ¶
func (s *UnixServer) SetAcceptErrorHandler(h func(error))
SetAcceptErrorHandler 当监听失败时的处理方法,此方法在监听协程执行,会阻塞监听 协程,处理完成之前无法监听新的连接。
func (*UnixServer) SetHandler ¶
SetHandler 设置连接建立后的处理方法,此方法会分到不同的Worker去执行,不阻塞 监听协程。
func (*UnixServer) SetRejectHandler ¶
SetRejectHandler 设置当连接数过多被拒绝时的处理方法,此方法在监听协程执 行,会阻塞监听协程,处理完成之前无法监听新的连接。
func (*UnixServer) SetWorkersPoolSize ¶
func (s *UnixServer) SetWorkersPoolSize(n ...uint32)
SetWorkersPoolSize 设置Worker数量 如果调用SetWorkersPoolSize(x)表示总共有x个workers,并且全部预先创建好; 如果调用SetWorkersPoolSize(y, x)表示总共有x个workers,只预先创建y个。