Versions in this module Expand all Collapse all v1 v1.3.2 Nov 10, 2020 Changes in this version + var CRLFByte = byte('\n') + func Serve(eventHandler EventHandler, protoAddr string, opts ...Option) (err error) + type Action int + const Close + const None + const Shutdown + type BuiltInFrameCodec struct + func (cc *BuiltInFrameCodec) Decode(c Conn) ([]byte, error) + func (cc *BuiltInFrameCodec) Encode(c Conn, buf []byte) ([]byte, error) + type Conn interface + AsyncWrite func(buf []byte) error + BufferLength func() (size int) + Close func() error + Context func() (ctx interface{}) + LocalAddr func() (addr net.Addr) + Read func() (buf []byte) + ReadN func(n int) (size int, buf []byte) + RemoteAddr func() (addr net.Addr) + ResetBuffer func() + SendTo func(buf []byte) error + SetContext func(ctx interface{}) + ShiftN func(n int) (size int) + Wake func() error + type DecoderConfig struct + ByteOrder binary.ByteOrder + InitialBytesToStrip int + LengthAdjustment int + LengthFieldLength int + LengthFieldOffset int + type DelimiterBasedFrameCodec struct + func NewDelimiterBasedFrameCodec(delimiter byte) *DelimiterBasedFrameCodec + func (cc *DelimiterBasedFrameCodec) Decode(c Conn) ([]byte, error) + func (cc *DelimiterBasedFrameCodec) Encode(c Conn, buf []byte) ([]byte, error) + type EncoderConfig struct + ByteOrder binary.ByteOrder + LengthAdjustment int + LengthFieldLength int + LengthIncludesLengthFieldLength bool + type EventHandler interface + OnClosed func(c Conn, err error) (action Action) + OnInitComplete func(server Server) (action Action) + OnOpened func(c Conn) (out []byte, action Action) + OnShutdown func(server Server) + PreWrite func() + React func(frame []byte, c Conn) (out []byte, action Action) + Tick func() (delay time.Duration, action Action) + type EventServer struct + func (es *EventServer) OnClosed(c Conn, err error) (action Action) + func (es *EventServer) OnInitComplete(svr Server) (action Action) + func (es *EventServer) OnOpened(c Conn) (out []byte, action Action) + func (es *EventServer) OnShutdown(svr Server) + func (es *EventServer) PreWrite() + func (es *EventServer) React(frame []byte, c Conn) (out []byte, action Action) + func (es *EventServer) Tick() (delay time.Duration, action Action) + type FixedLengthFrameCodec struct + func NewFixedLengthFrameCodec(frameLength int) *FixedLengthFrameCodec + func (cc *FixedLengthFrameCodec) Decode(c Conn) ([]byte, error) + func (cc *FixedLengthFrameCodec) Encode(c Conn, buf []byte) ([]byte, error) + type ICodec interface + Decode func(c Conn) ([]byte, error) + Encode func(c Conn, buf []byte) ([]byte, error) + type LengthFieldBasedFrameCodec struct + func NewLengthFieldBasedFrameCodec(ec EncoderConfig, dc DecoderConfig) *LengthFieldBasedFrameCodec + func (cc *LengthFieldBasedFrameCodec) Decode(c Conn) ([]byte, error) + func (cc *LengthFieldBasedFrameCodec) Encode(c Conn, buf []byte) (out []byte, err error) + type LineBasedFrameCodec struct + func (cc *LineBasedFrameCodec) Decode(c Conn) ([]byte, error) + func (cc *LineBasedFrameCodec) Encode(c Conn, buf []byte) ([]byte, error) + type LoadBalancing int + const LeastConnections + const RoundRobin + const SourceAddrHash + type Option func(opts *Options) + func WithCodec(codec ICodec) Option + func WithLoadBalancing(lb LoadBalancing) Option + func WithLockOSThread(lockOSThread bool) Option + func WithLogger(logger logging.Logger) Option + func WithMulticore(multicore bool) Option + func WithNumEventLoop(numEventLoop int) Option + func WithOptions(options Options) Option + func WithReusePort(reusePort bool) Option + func WithTCPKeepAlive(tcpKeepAlive time.Duration) Option + func WithTicker(ticker bool) Option + type Options struct + Codec ICodec + LB LoadBalancing + LockOSThread bool + Logger logging.Logger + Multicore bool + NumEventLoop int + ReusePort bool + TCPKeepAlive time.Duration + Ticker bool + type Server struct + Addr net.Addr + Multicore bool + NumEventLoop int + ReusePort bool + TCPKeepAlive time.Duration + func (s Server) CountConnections() (count int)