Documentation ¶
Index ¶
- Constants
- func HandleSignals(onTrapped func(s os.Signal)) (waiter func())
- func NewRingBuffer(size int64) *ringbuf.RingBuffer
- func StopServer(s *Server)
- type Client
- type ClientOpt
- func WithClientOnConnectedFunc(fn OnTcpConnectedFunc) ClientOpt
- func WithClientOnDisconnectedFunc(fn OnTcpDisconnectedFunc) ClientOpt
- func WithClientOnProcessFunc(fn OnTcpProcessFunc) ClientOpt
- func WithClientReadBufferSize(size int) ClientOpt
- func WithClientTlsConfig(s *tls.CmdrTlsConfig) ClientOpt
- type OnTcpConnectedFunc
- type OnTcpDisconnectedFunc
- type OnTcpProcessFunc
- type OnTcpServerConnectedWithClient
- type OnTcpServerCreateReadWriter
- type OnTcpServerDisconnectedWithClient
- type OnTcpServerListening
- type OnTcpServerProcessFunc
- type Processor
- type Server
- type ServerOpt
- func WithServerBufferSize(size int) ServerOpt
- func WithServerConnectedWithClient(fn OnTcpServerConnectedWithClient) ServerOpt
- func WithServerDisconnectedWithClient(fn OnTcpServerDisconnectedWithClient) ServerOpt
- func WithServerListening(fn OnTcpServerListening) ServerOpt
- func WithServerOnProcessFunc(onProcess OnTcpServerProcessFunc) ServerOpt
- func WithServerReadWriter(onCreateReadWriter OnTcpServerCreateReadWriter) ServerOpt
- func WithTlsConfig(s *tls.CmdrTlsConfig) ServerOpt
Constants ¶
View Source
const (
DefaultBufferSize = 4096
)
Variables ¶
This section is empty.
Functions ¶
func HandleSignals ¶
func NewRingBuffer ¶
func NewRingBuffer(size int64) *ringbuf.RingBuffer
NewRingBuffer will allocate, initialize, and return a ring buffer with the specified size.
func StopServer ¶
func StopServer(s *Server)
Types ¶
type Client ¶
type Client struct { CmdrTlsConfig *tls.CmdrTlsConfig // contains filtered or unexported fields }
type ClientOpt ¶
type ClientOpt func(*Client)
func WithClientOnConnectedFunc ¶
func WithClientOnConnectedFunc(fn OnTcpConnectedFunc) ClientOpt
func WithClientOnDisconnectedFunc ¶
func WithClientOnDisconnectedFunc(fn OnTcpDisconnectedFunc) ClientOpt
func WithClientOnProcessFunc ¶
func WithClientOnProcessFunc(fn OnTcpProcessFunc) ClientOpt
func WithClientTlsConfig ¶
func WithClientTlsConfig(s *tls.CmdrTlsConfig) ClientOpt
type OnTcpConnectedFunc ¶
type OnTcpDisconnectedFunc ¶
type OnTcpDisconnectedFunc func(c *Client)
type OnTcpProcessFunc ¶
type OnTcpServerListening ¶
type OnTcpServerProcessFunc ¶
type Processor ¶
type Processor interface { // Process implements Processor interface to announce that i will process the incoming data in Read(). Process(buf []byte, in io.Reader, out io.Writer) (nn int, err error) }
Processor 代表在reader处理读取到到报文的同时会立即进行报文的处理。
Reader负责从读取的报文数据块中按照协议进行分包,切分成功 的包(Packet)将被Processor所处理以完成业务逻辑。
如果Reader并未实现Processor接口,Server将会把识别到到 包交给 OnTcpServerProcessFunc 去处理。
type Server ¶
type Server struct { CmdrTlsConfig *tls.CmdrTlsConfig // contains filtered or unexported fields }
func StartServer ¶
type ServerOpt ¶
type ServerOpt func(*Server)
func WithServerBufferSize ¶
func WithServerConnectedWithClient ¶
func WithServerConnectedWithClient(fn OnTcpServerConnectedWithClient) ServerOpt
func WithServerDisconnectedWithClient ¶
func WithServerDisconnectedWithClient(fn OnTcpServerDisconnectedWithClient) ServerOpt
func WithServerListening ¶
func WithServerListening(fn OnTcpServerListening) ServerOpt
func WithServerOnProcessFunc ¶
func WithServerOnProcessFunc(onProcess OnTcpServerProcessFunc) ServerOpt
func WithServerReadWriter ¶
func WithServerReadWriter(onCreateReadWriter OnTcpServerCreateReadWriter) ServerOpt
func WithTlsConfig ¶
func WithTlsConfig(s *tls.CmdrTlsConfig) ServerOpt
Source Files ¶
Click to show internal directories.
Click to hide internal directories.