Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (client *Client) AsyncWrite(buf []byte, callback func(c session.Conn, err error) error)
- func (client *Client) Close() error
- func (client *Client) CloseWithContext(ctx context.Context) error
- func (client *Client) Connection() session.Conn
- func (client *Client) Dial(ctx context.Context, address string) error
- func (client *Client) IsClosed() bool
- func (client *Client) SendMessage(message any)
- func (client *Client) SendMessages(messages ...any)
- func (client *Client) Status() uint32
- type Conn
- func (conn *Conn) AsyncWrite(buf []byte, callback func(c session.Conn, err error) error) (err error)
- func (conn *Conn) AsyncWritev(bs [][]byte, callback func(c session.Conn, err error) error) (err error)
- func (conn *Conn) Close() error
- func (conn *Conn) Context() (ctx any)
- func (conn *Conn) Discard(n int) (discarded int, err error)
- func (conn *Conn) Flush() (err error)
- func (conn *Conn) InboundBuffered() (n int)
- func (conn *Conn) Init(client *Client, pConn *net.TCPConn) error
- func (conn *Conn) Next(n int) (buf []byte, err error)
- func (conn *Conn) OutboundBuffered() (n int)
- func (conn *Conn) Peek(n int) (buf []byte, err error)
- func (conn *Conn) Read(b []byte) (n int, err error)
- func (conn *Conn) ReadFrom(r io.Reader) (n int64, err error)
- func (conn *Conn) SetContext(_ interface{})
- func (conn *Conn) ToClosed(reason error) bool
- func (conn *Conn) Write(b []byte) (n int, err error)
- func (conn *Conn) WriteTo(w io.Writer) (n int64, err error)
- func (conn *Conn) Writev(bs [][]byte) (n int, err error)
- type Option
- func WithName(value string) Option
- func WithReadBufferCap(cap int) Option
- func WithSocketRecvBuffer(cap int) Option
- func WithSocketSendBuffer(cap int) Option
- func WithTCPKeepAlive(value time.Duration) Option
- func WithTCPNoDelay(value bool) Option
- func WithWriteBufferCap(cap int) Option
- func WithWriteQueueCap(cap int) Option
- type Options
Constants ¶
View Source
const ( StatusInitial = iota StatusConnecting StatusConnected StatusClosed )
Variables ¶
View Source
var (
ErrInvalidStatus = errors.New("invalid client status")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *Options session.BaseSession // contains filtered or unexported fields }
func (*Client) AsyncWrite ¶ added in v0.0.7
AsyncWrite
@Description: 异步写字节数组数据 @receiver client @param buf @param callback
func (*Client) Connection ¶
func (*Client) Dial ¶
Dial
@Description: 连接 @receiver client @param ctx @param address 如:127.0.0.1:9999 @return error
type Conn ¶
func (*Conn) AsyncWrite ¶
func (*Conn) AsyncWritev ¶
func (*Conn) InboundBuffered ¶
func (*Conn) OutboundBuffered ¶
func (*Conn) SetContext ¶
func (conn *Conn) SetContext(_ interface{})
type Option ¶
type Option func(*Options)
func WithReadBufferCap ¶
func WithSocketRecvBuffer ¶
func WithSocketSendBuffer ¶
func WithTCPKeepAlive ¶
func WithTCPNoDelay ¶
func WithWriteBufferCap ¶
func WithWriteQueueCap ¶
type Options ¶
type Options struct { Name string // 读缓冲容量 ReadBufferCap int // 写缓冲容量 WriteBufferCap int // 同时提交写队列上限,队列满时异步写直接返回错误 WriteQueueCap int // 保活时间 TCPKeepAlive time.Duration // TCPNoDelay controls whether the operating system should delay // packet transmission in hopes of sending fewer packets (Nagle's algorithm). TCPNoDelay bool // socket读缓冲区 SocketRecvBuffer int // socket写缓冲区 SocketSendBuffer int }
Click to show internal directories.
Click to hide internal directories.