Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NBO = binary.BigEndian
NBO is NetworkByteOrder
Functions ¶
This section is empty.
Types ¶
type Chan ¶
Chan is a msgio duplex channel. It is used to have a channel interface around a msgio.Reader or Writer.
func (*Chan) ReadFrom ¶
ReadFrom wraps the given io.Reader with a msgio.Reader, reads all messages, ands sends them down the channel.
func (*Chan) ReadFromWithPool ¶
ReadFromWithPool wraps the given io.Reader with a msgio.Reader, reads all messages, ands sends them down the channel. Uses given Pool
type ReadCloser ¶
ReadCloser combines a Reader and Closer.
func NewReader ¶
func NewReader(r io.Reader) ReadCloser
NewReader wraps an io.Reader with a msgio framed reader. The msgio.Reader will read whole messages at a time (using the length). Assumes an equivalent writer on the other side.
func NewReaderWithPool ¶
func NewReaderWithPool(r io.Reader, p *mpool.Pool) ReadCloser
NewReaderWithPool wraps an io.Reader with a msgio framed reader. The msgio.Reader will read whole messages at a time (using the length). Assumes an equivalent writer on the other side. It uses a given mpool.Pool
func NewVarintReader ¶
func NewVarintReader(r io.Reader) ReadCloser
NewVarintReader wraps an io.Reader with a varint msgio framed reader. The msgio.Reader will read whole messages at a time (using the length). Varints read according to https://golang.org/pkg/encoding/binary/#ReadUvarint Assumes an equivalent writer on the other side.
func NewVarintReaderWithPool ¶
func NewVarintReaderWithPool(r io.Reader, p *mpool.Pool) ReadCloser
NewVarintReaderWithPool wraps an io.Reader with a varint msgio framed reader. The msgio.Reader will read whole messages at a time (using the length). Varints read according to https://golang.org/pkg/encoding/binary/#ReadUvarint Assumes an equivalent writer on the other side. It uses a given mpool.Pool
type ReadWriteCloser ¶
ReadWriteCloser combines a Reader, a Writer, and Closer.
func Combine ¶
func Combine(w Writer, r Reader) ReadWriteCloser
Combine wraps a pair of msgio.Writer and msgio.Reader with a msgio.ReadWriter.
func NewReadWriter ¶
func NewReadWriter(rw io.ReadWriter) ReadWriteCloser
NewReadWriter wraps an io.ReadWriter with a msgio.ReadWriter. Writing and Reading will be appropriately framed.
type ReadWriter ¶
ReadWriter combines a Reader and Writer.
type Reader ¶
type Reader interface { // Read reads the next message from the Reader. // The client must pass a buffer large enough, or io.ErrShortBuffer will be // returned. Read([]byte) (int, error) // ReadMsg reads the next message from the Reader. // Uses a mpool.Pool internally to reuse buffers. io.ErrShortBuffer will // be returned if the Pool.Get(...) returns nil. // User may call ReleaseMsg(msg) to signal a buffer can be reused. ReadMsg() ([]byte, error) // ReleaseMsg signals a buffer can be reused. ReleaseMsg([]byte) // NextMsgLen returns the length of the next (peeked) message. Does // not destroy the message or have other adverse effects NextMsgLen() (int, error) }
Reader is the msgio Reader interface. It reads len-framed messages.
type WriteCloser ¶
WriteCloser is a Writer + Closer interface. Like in `golang/pkg/io`
func NewVarintWriter ¶
func NewVarintWriter(w io.Writer) WriteCloser
NewVarintWriter wraps an io.Writer with a varint msgio framed writer. The msgio.Writer will write the length prefix of every message written as a varint, using https://golang.org/pkg/encoding/binary/#PutUvarint
func NewWriter ¶
func NewWriter(w io.Writer) WriteCloser
NewWriter wraps an io.Writer with a msgio framed writer. The msgio.Writer will write the length prefix of every message written.