Documentation ¶
Overview ¶
Package chunk provides a high level chunking client. A chunk is defined as a defined amount of data. A chunk client will work with *uds.Client, *uds.Conn object for chunking in clients and servers.
The high level RPC clients in all packages use chunk underneath.
A chunk client simply writes a variadic int to indicate the next message size to be written and then writes the message. On a read call it reads the int indicating the size and then reads in that amount of buffer.
The format is:
[varint][data chunk]
The chunk client can set a maximum message size.
If a read error occurs, the chunk client will close the connection. Read errors should only happen if the maximum message size is exceeded or io.EOF to indicate the socket is closed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a wrapper around an *uds.Client or *uds.Server that can send data chunks.
func New ¶
func New(rwc io.ReadWriteCloser, options ...Option) (*Client, error)
New is the constructor for Client. rwc must be a *uds.Client or *uds.Conn.
func (*Client) ClosedSignal ¶ added in v1.1.1
func (c *Client) ClosedSignal() chan struct{}
ClosedSignal returns a channel that will be closed when this Client becomes closed.
type Option ¶
type Option func(c *Client)
Option is an optional argument to New.
func MaxSize ¶
MaxSize is the maximum size a read message is allowed to be. If a message is larger than this, Next() will fail and the underlying connection will be closed.
func SharedPool ¶
SharedPool allows the use of a shared pool of buffers between Client instead of a pool per client. This is useful when clients are short lived and have similar message sizes. Client will panic if the pool does not return a *[]byte object.
type Pool ¶ added in v1.1.0
type Pool struct {
// contains filtered or unexported fields
}
Pool is a memory pool for buffers.
func NewPool ¶ added in v1.1.0
NewPool is the constructor for Pool. cap is capacity of an internal free list before using a sync.Pool.