Documentation ¶
Index ¶
- Variables
- func LimitListener(l net.Listener, n int) net.Listener
- func SetLogger(logger Logger)
- func TCPListen(addr string) (ln net.Listener, err error)
- type 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
- type 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
- type ClientFactory
- type ClientPool
- type ClientPoolConfig
- type Conn
- 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
- type IoConfig
- type IoHandler
- type IoHandlerAdapter
- type IoService
- type 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
- 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
- type Logger
- type Message
- type Protocol
- type ProtocolDecoder
- type ProtocolEncoder
- type Request
- type Response
- type Server
- type ServerBase
- type ServerConfig
- type TCPClient
- type TCPClientConfig
- type TCPListener
- type TCPServer
- type TCPServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrClientClosed = errors.New("client closed") ErrClientDisconnected = errors.New("client disconnected") )
View Source
var ( ErrSessionClosed = errors.New("session closed") ErrPeerDead = errors.New("peer dead") ErrTimeout = errors.New("timeout") )
View Source
var ErrClientPoolClosed = errors.New("client manager closed")
View Source
var ErrServerClosed = errors.New("server closed")
Functions ¶
func LimitListener ¶
LimitListener returns a Listener that accepts at most n simultaneous connections from the provided Listener.
Types ¶
type CircuitBreakerClient ¶
type CircuitBreakerClient struct { Client // contains filtered or unexported fields }
func NewCircuitBreakerClient ¶
func NewCircuitBreakerClient(client Client, breaker *gobreaker.CircuitBreaker) *CircuitBreakerClient
func (*CircuitBreakerClient) CallWithTimeout ¶
func (*CircuitBreakerClient) Dial ¶
func (c *CircuitBreakerClient) Dial(addr string) (err error)
func (*CircuitBreakerClient) Send ¶
func (c *CircuitBreakerClient) Send(ctx context.Context, msg Message) (err error)
func (*CircuitBreakerClient) SendWithTimeout ¶
type Client ¶
type Client interface { Dial(addr string) error Close() Disconnect() SetProtocol(Protocol) SetIoHandler(h IoHandler) Call(ctx context.Context, req Request) (Response, error) CallWithTimeout(ctx context.Context, req Request, timeout time.Duration) (Response, error) Send(ctx context.Context, msg Message) error SendWithTimeout(ctx context.Context, msg Message, timeout time.Duration) error GetSession() *IoSession IsClosed() bool IsConnected() bool }
type ClientBase ¶
type ClientBase struct { *IoServiceBase sync.Mutex // contains filtered or unexported fields }
func NewClientBase ¶
func NewClientBase(ctx context.Context, dial DialFunc, conf *ClientConfig) *ClientBase
func (*ClientBase) CallWithTimeout ¶
func (*ClientBase) Close ¶
func (c *ClientBase) Close()
func (*ClientBase) Dial ¶
func (c *ClientBase) Dial(addr string) (err error)
func (*ClientBase) Disconnect ¶
func (c *ClientBase) Disconnect()
func (*ClientBase) GetSession ¶
func (c *ClientBase) GetSession() (session *IoSession)
func (*ClientBase) IsClosed ¶
func (c *ClientBase) IsClosed() (closed bool)
func (*ClientBase) IsConnected ¶
func (c *ClientBase) IsConnected() bool
func (*ClientBase) OnConnected ¶
func (c *ClientBase) OnConnected(session *IoSession) error
func (*ClientBase) OnDisconnected ¶
func (c *ClientBase) OnDisconnected(session *IoSession)
func (*ClientBase) OnError ¶
func (c *ClientBase) OnError(session *IoSession, err error)
func (*ClientBase) OnIdle ¶
func (c *ClientBase) OnIdle(session *IoSession) error
func (*ClientBase) OnMessage ¶
func (c *ClientBase) OnMessage(session *IoSession, msg Message) error
func (*ClientBase) SendWithTimeout ¶
func (*ClientBase) SetIoHandler ¶
func (c *ClientBase) SetIoHandler(h IoHandler)
type ClientConfig ¶
type ClientConfig struct { Io struct { SendQueueSize int RecvQueueSize int ReadTimeout time.Duration WriteTimeout time.Duration } AutoReconnect bool }
func NewClientConfig ¶
func NewClientConfig() *ClientConfig
type ClientFactory ¶
type ClientPool ¶
func NewClientPool ¶
func NewClientPool(ctx context.Context, factory ClientFactory, conf ClientPoolConfig) *ClientPool
func (*ClientPool) Close ¶
func (p *ClientPool) Close()
func (*ClientPool) Get ¶
func (p *ClientPool) Get() Client
func (*ClientPool) Open ¶
func (p *ClientPool) Open() error
type ClientPoolConfig ¶
type DialFunc ¶
func TCPDialFunc ¶
type IoHandlerAdapter ¶
type IoHandlerAdapter struct { }
func (*IoHandlerAdapter) OnConnected ¶
func (h *IoHandlerAdapter) OnConnected(*IoSession) error
func (*IoHandlerAdapter) OnDisconnected ¶
func (h *IoHandlerAdapter) OnDisconnected(*IoSession)
func (*IoHandlerAdapter) OnError ¶
func (h *IoHandlerAdapter) OnError(*IoSession, error)
func (*IoHandlerAdapter) OnIdle ¶
func (h *IoHandlerAdapter) OnIdle(*IoSession) error
type IoServiceBase ¶
type IoServiceBase struct {
// contains filtered or unexported fields
}
func NewIoServiceBase ¶
func NewIoServiceBase(conf *IoConfig) *IoServiceBase
func (*IoServiceBase) AddRef ¶
func (srv *IoServiceBase) AddRef()
func (*IoServiceBase) DecRef ¶
func (srv *IoServiceBase) DecRef()
func (*IoServiceBase) IoConfig ¶
func (srv *IoServiceBase) IoConfig() *IoConfig
func (*IoServiceBase) IoHandler ¶
func (srv *IoServiceBase) IoHandler() IoHandler
func (*IoServiceBase) NextSessionId ¶
func (srv *IoServiceBase) NextSessionId() uint64
func (*IoServiceBase) Protocol ¶
func (srv *IoServiceBase) Protocol() Protocol
func (*IoServiceBase) SetIoHandler ¶
func (srv *IoServiceBase) SetIoHandler(h IoHandler)
func (*IoServiceBase) SetProtocol ¶
func (srv *IoServiceBase) SetProtocol(p Protocol)
type IoSession ¶
type IoSession struct {
// contains filtered or unexported fields
}
func (*IoSession) GetIdleCount ¶
func (*IoSession) IsConnected ¶
func (*IoSession) RemoteAddr ¶
func (*IoSession) RemoveAttr ¶
func (*IoSession) SendWithTimeout ¶
type Protocol ¶
type Protocol interface { ProtocolEncoder ProtocolDecoder }
type ProtocolDecoder ¶
type ProtocolEncoder ¶
type ServerBase ¶
type ServerBase struct { *IoServiceBase // contains filtered or unexported fields }
func NewServerBase ¶
func NewServerBase(ctx context.Context, listen ListenFunc, conf *ServerConfig) *ServerBase
func (*ServerBase) AddRef ¶
func (srv *ServerBase) AddRef()
func (*ServerBase) Close ¶
func (srv *ServerBase) Close()
func (*ServerBase) DecRef ¶
func (srv *ServerBase) DecRef()
func (*ServerBase) ListenAndServe ¶
func (srv *ServerBase) ListenAndServe(addr string) error
type ServerConfig ¶
type ServerConfig struct { Io struct { SendQueueSize int RecvQueueSize int ReadTimeout time.Duration WriteTimeout time.Duration } MaxConnection int }
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
type TCPClient ¶
type TCPClient struct {
*ClientBase
}
func NewTCPClient ¶
func NewTCPClient(ctx context.Context, conf *TCPClientConfig) *TCPClient
type TCPClientConfig ¶
type TCPClientConfig struct { Io struct { SendQueueSize int RecvQueueSize int ReadTimeout time.Duration WriteTimeout time.Duration } DialTimeout time.Duration AutoReconnect bool }
func NewTCPClientConfig ¶
func NewTCPClientConfig() *TCPClientConfig
type TCPListener ¶
type TCPListener struct {
*net.TCPListener
}
type TCPServer ¶
type TCPServer struct {
*ServerBase
}
func NewTCPServer ¶
func NewTCPServer(ctx context.Context, conf *TCPServerConfig) *TCPServer
type TCPServerConfig ¶
type TCPServerConfig ServerConfig
func NewTCPServerConfig ¶
func NewTCPServerConfig() *TCPServerConfig
Source Files ¶
Click to show internal directories.
Click to hide internal directories.