Versions in this module Expand all Collapse all v2 v2.5.2 Apr 24, 2024 v2.5.1 Apr 24, 2024 Changes in this version + var MaxStreamBufferCap = 64 * 1024 + func Rotate(eventHandler EventHandler, addrs []string, opts ...Option) error + func Run(eventHandler EventHandler, protoAddr string, opts ...Option) error + func Stop(ctx context.Context, protoAddr string) error + type Action int + const Close + const None + const Shutdown + type AsyncCallback func(c Conn, err error) error + type BuiltinEventEngine struct + func (*BuiltinEventEngine) OnBoot(_ Engine) (action Action) + func (*BuiltinEventEngine) OnClose(_ Conn, _ error) (action Action) + func (*BuiltinEventEngine) OnOpen(_ Conn) (out []byte, action Action) + func (*BuiltinEventEngine) OnShutdown(_ Engine) + func (*BuiltinEventEngine) OnTick() (delay time.Duration, action Action) + func (*BuiltinEventEngine) OnTraffic(_ Conn) (action Action) + type Client struct + func NewClient(eh EventHandler, opts ...Option) (cli *Client, err error) + func (cli *Client) Dial(network, addr string) (Conn, error) + func (cli *Client) DialContext(network, addr string, ctx interface{}) (Conn, error) + func (cli *Client) Enroll(nc net.Conn) (gc Conn, err error) + func (cli *Client) EnrollContext(nc net.Conn, ctx interface{}) (gc Conn, err error) + func (cli *Client) Start() error + func (cli *Client) Stop() (err error) + type Conn interface + Close func() (err error) + CloseWithCallback func(callback AsyncCallback) (err error) + Context func() (ctx interface{}) + LocalAddr func() (addr net.Addr) + RemoteAddr func() (addr net.Addr) + SetContext func(ctx interface{}) + SetDeadline func(t time.Time) (err error) + SetReadDeadline func(t time.Time) (err error) + SetWriteDeadline func(t time.Time) (err error) + Wake func(callback AsyncCallback) (err error) + type Engine struct + func (e Engine) CountConnections() (count int) + func (e Engine) Dup() (fd int, err error) + func (e Engine) Stop(ctx context.Context) error + func (e Engine) Validate() error + type EventHandler interface + OnBoot func(eng Engine) (action Action) + OnClose func(c Conn, err error) (action Action) + OnOpen func(c Conn) (out []byte, action Action) + OnShutdown func(eng Engine) + OnTick func() (delay time.Duration, action Action) + OnTraffic func(c Conn) (action Action) + type LoadBalancing int + const LeastConnections + const RoundRobin + const SourceAddrHash + type Option func(opts *Options) + func WithEdgeTriggeredIO(et bool) Option + func WithLoadBalancing(lb LoadBalancing) Option + func WithLockOSThread(lockOSThread bool) Option + func WithLogLevel(lvl logging.Level) Option + func WithLogPath(fileName string) Option + func WithLogger(logger logging.Logger) Option + func WithMulticastInterfaceIndex(idx int) Option + func WithMulticore(multicore bool) Option + func WithNumEventLoop(numEventLoop int) Option + func WithOptions(options Options) Option + func WithReadBufferCap(readBufferCap int) Option + func WithReuseAddr(reuseAddr bool) Option + func WithReusePort(reusePort bool) Option + func WithSocketRecvBuffer(recvBuf int) Option + func WithSocketSendBuffer(sendBuf int) Option + func WithTCPKeepAlive(tcpKeepAlive time.Duration) Option + func WithTCPNoDelay(tcpNoDelay TCPSocketOpt) Option + func WithTicker(ticker bool) Option + func WithWriteBufferCap(writeBufferCap int) Option + type Options struct + EdgeTriggeredIO bool + LB LoadBalancing + LockOSThread bool + LogLevel logging.Level + LogPath string + Logger logging.Logger + MulticastInterfaceIndex int + Multicore bool + NumEventLoop int + ReadBufferCap int + ReuseAddr bool + ReusePort bool + SocketRecvBuffer int + SocketSendBuffer int + TCPKeepAlive time.Duration + TCPNoDelay TCPSocketOpt + Ticker bool + WriteBufferCap int + type Reader interface + Discard func(n int) (discarded int, err error) + InboundBuffered func() (n int) + Next func(n int) (buf []byte, err error) + Peek func(n int) (buf []byte, err error) + type Socket interface + Dup func() (int, error) + Fd func() int + SetKeepAlivePeriod func(d time.Duration) error + SetLinger func(sec int) error + SetNoDelay func(noDelay bool) error + SetReadBuffer func(bytes int) error + SetWriteBuffer func(bytes int) error + type TCPSocketOpt int + const TCPDelay + const TCPNoDelay + type Writer interface + AsyncWrite func(buf []byte, callback AsyncCallback) (err error) + AsyncWritev func(bs [][]byte, callback AsyncCallback) (err error) + Flush func() (err error) + OutboundBuffered func() (n int) + Writev func(bs [][]byte) (n int, err error)