Versions in this module Expand all Collapse all v1 v1.0.0 Jun 9, 2021 Changes in this version + var ErrClientClosed = errors.New("client closed") + var ErrClientDisconnected = errors.New("client disconnected") + var ErrClientPoolClosed = errors.New("client manager closed") + var ErrPeerDead = errors.New("peer dead") + var ErrServerClosed = errors.New("server closed") + var ErrSessionClosed = errors.New("session closed") + var ErrTimeout = errors.New("timeout") + func LimitListener(l net.Listener, n int) net.Listener + func SetLogger(logger Logger) + func TCPListen(addr string) (ln net.Listener, err error) + type CircuitBreakerClient struct + func NewCircuitBreakerClient(client Client, breaker *gobreaker.CircuitBreaker) *CircuitBreakerClient + func (c *CircuitBreakerClient) Call(ctx context.Context, req Request) (resp Response, err error) + func (c *CircuitBreakerClient) CallWithTimeout(ctx context.Context, req Request, timeout time.Duration) (resp Response, err error) + func (c *CircuitBreakerClient) Dial(addr string) (err error) + func (c *CircuitBreakerClient) Send(ctx context.Context, msg Message) (err error) + func (c *CircuitBreakerClient) SendWithTimeout(ctx context.Context, msg Message, timeout time.Duration) (err error) + type Client interface + Call func(ctx context.Context, req Request) (Response, error) + CallWithTimeout func(ctx context.Context, req Request, timeout time.Duration) (Response, error) + Close func() + Dial func(addr string) error + Disconnect func() + GetSession func() *IoSession + IsClosed func() bool + IsConnected func() bool + Send func(ctx context.Context, msg Message) error + SendWithTimeout func(ctx context.Context, msg Message, timeout time.Duration) error + SetIoHandler func(h IoHandler) + SetProtocol func(Protocol) + type ClientBase struct + func NewClientBase(ctx context.Context, dial DialFunc, conf *ClientConfig) *ClientBase + func (c *ClientBase) Call(ctx context.Context, req Request) (Response, error) + func (c *ClientBase) CallWithTimeout(ctx context.Context, req Request, timeout time.Duration) (resp Response, err error) + func (c *ClientBase) Close() + func (c *ClientBase) Dial(addr string) (err error) + func (c *ClientBase) Disconnect() + func (c *ClientBase) GetSession() (session *IoSession) + func (c *ClientBase) IsClosed() (closed bool) + func (c *ClientBase) IsConnected() bool + func (c *ClientBase) OnConnected(session *IoSession) error + func (c *ClientBase) OnDisconnected(session *IoSession) + func (c *ClientBase) OnError(session *IoSession, err error) + func (c *ClientBase) OnIdle(session *IoSession) error + func (c *ClientBase) OnMessage(session *IoSession, msg Message) error + func (c *ClientBase) Send(ctx context.Context, msg Message) error + func (c *ClientBase) SendWithTimeout(ctx context.Context, msg Message, timeout time.Duration) (err error) + func (c *ClientBase) SetIoHandler(h IoHandler) + type ClientConfig struct + AutoReconnect bool + Io struct{ ... } + func NewClientConfig() *ClientConfig + type ClientFactory interface + NewClient func() (Client, error) + type ClientPool struct + func NewClientPool(ctx context.Context, factory ClientFactory, conf ClientPoolConfig) *ClientPool + func (p *ClientPool) Close() + func (p *ClientPool) Get() Client + func (p *ClientPool) Open() error + type ClientPoolConfig struct + IdleMax int + IdleMin int + Max int + type Conn struct + func (c *Conn) GetReadBytes() uint32 + func (c *Conn) GetWriteBytes() uint32 + func (c *Conn) Read(b []byte) (n int, err error) + func (c *Conn) SetReadTimeout(d time.Duration) (err error) + func (c *Conn) SetTimeout(d time.Duration) + func (c *Conn) SetWriteTimeout(d time.Duration) (err error) + func (c *Conn) Write(b []byte) (n int, err error) + type DialFunc func(addr string) (net.Conn, error) + func TCPDialFunc(timeout time.Duration) DialFunc + type IoConfig struct + ReadTimeout time.Duration + RecvQueueSize int + SendQueueSize int + WriteTimeout time.Duration + type IoHandler interface + OnConnected func(*IoSession) error + OnDisconnected func(*IoSession) + OnError func(*IoSession, error) + OnIdle func(*IoSession) error + OnMessage func(*IoSession, Message) error + type IoHandlerAdapter struct + func (h *IoHandlerAdapter) OnConnected(*IoSession) error + func (h *IoHandlerAdapter) OnDisconnected(*IoSession) + func (h *IoHandlerAdapter) OnError(*IoSession, error) + func (h *IoHandlerAdapter) OnIdle(*IoSession) error + func (h *IoHandlerAdapter) OnMessage(*IoSession, Message) error + type IoService interface + AddRef func() + DecRef func() + IoConfig func() *IoConfig + IoHandler func() IoHandler + NextSessionId func() uint64 + Protocol func() Protocol + type IoServiceBase struct + func NewIoServiceBase(conf *IoConfig) *IoServiceBase + func (srv *IoServiceBase) AddRef() + func (srv *IoServiceBase) DecRef() + func (srv *IoServiceBase) IoConfig() *IoConfig + func (srv *IoServiceBase) IoHandler() IoHandler + func (srv *IoServiceBase) NextSessionId() uint64 + func (srv *IoServiceBase) Protocol() Protocol + func (srv *IoServiceBase) SetIoHandler(h IoHandler) + func (srv *IoServiceBase) SetProtocol(p Protocol) + type IoSession struct + func NewIoSession(ctx context.Context, srv IoService, conn net.Conn) *IoSession + func (s *IoSession) Close() + func (s *IoSession) Context() context.Context + func (s *IoSession) GetAttr(key interface{}) (v interface{}) + func (s *IoSession) GetIdleCount() uint32 + func (s *IoSession) Id() uint64 + func (s *IoSession) IoService() IoService + func (s *IoSession) IsClosed() bool + func (s *IoSession) IsConnected() bool + func (s *IoSession) LocalAddr() net.Addr + func (s *IoSession) Open() + func (s *IoSession) RemoteAddr() net.Addr + func (s *IoSession) RemoveAttr(key string) + func (s *IoSession) Send(ctx context.Context, m Message) error + func (s *IoSession) SendWithTimeout(ctx context.Context, m Message, timeout time.Duration) error + func (s *IoSession) SetAttr(key, value interface{}) + func (s *IoSession) String() string + type ListenFunc func(addr string) (net.Listener, error) + type Logger interface + Printf func(fmt string, args ...interface{}) + type Message interface + type Protocol interface + type ProtocolDecoder interface + Decode func(*IoSession, io.Reader) (Message, error) + type ProtocolEncoder interface + Encode func(*IoSession, Message) ([]byte, error) + type Request interface + Id func() uint64 + type Response interface + Id func() uint64 + type Server interface + Close func() + ListenAndServe func(addr string) error + Serve func(ln net.Listener) error + type ServerBase struct + func NewServerBase(ctx context.Context, listen ListenFunc, conf *ServerConfig) *ServerBase + func (srv *ServerBase) AddRef() + func (srv *ServerBase) Close() + func (srv *ServerBase) DecRef() + func (srv *ServerBase) ListenAndServe(addr string) error + func (srv *ServerBase) Serve(l net.Listener) error + type ServerConfig struct + Io struct{ ... } + MaxConnection int + func NewServerConfig() *ServerConfig + type TCPClient struct + func NewTCPClient(ctx context.Context, conf *TCPClientConfig) *TCPClient + type TCPClientConfig struct + AutoReconnect bool + DialTimeout time.Duration + Io struct{ ... } + func NewTCPClientConfig() *TCPClientConfig + type TCPListener struct + func (ln TCPListener) Accept() (c net.Conn, err error) + type TCPServer struct + func NewTCPServer(ctx context.Context, conf *TCPServerConfig) *TCPServer + type TCPServerConfig ServerConfig + func NewTCPServerConfig() *TCPServerConfig