Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncWriter ¶
type AsyncWriter struct { *Writer // contains filtered or unexported fields }
func NewAsyncWriter ¶
func NewAsyncWriter(w io.Writer) *AsyncWriter
func (*AsyncWriter) Flush ¶
func (w *AsyncWriter) Flush() error
Flush waits for all async writes to complete and forces the flush of internal buffers.
func (*AsyncWriter) WriteLineAsync ¶
func (w *AsyncWriter) WriteLineAsync(data []byte) error
WriteLineAsync writes a single protocol message. The message won't be written immediately and will be batched with other similar messages.
type ErrProtocolViolation ¶
type ErrProtocolViolation struct {
Err error
}
func (*ErrProtocolViolation) Error ¶
func (e *ErrProtocolViolation) Error() string
type Reader ¶
type Reader struct { // Safe can be set to disable internal mutex. Safe bool // OnLine is called each time a raw protocol line is read from the connection. // The buffer will contain a delimiter and is in the connection encoding. // The function may return (false, nil) to ignore the message. OnLine func(line []byte) (bool, error) // contains filtered or unexported fields }
Reader is safe for concurrent use.
func (*Reader) ReadLine ¶
ReadLine reads a single raw message until the delimiter. The returned buffer contains a delimiter and is in the connection encoding. The buffer is only valid until the next call to Read or ReadLine.
func (*Reader) SetMaxLine ¶
SetMaxLine sets a maximal length of the protocol messages in bytes, including the delimiter.
type Writer ¶
type Writer struct { // OnLine is called each time a raw protocol message is written. // The function may return (false, nil) to skip writing the message. OnLine func(line []byte) (bool, error) // contains filtered or unexported fields }
Writer is safe for concurrent use.
func (*Writer) EndBatch ¶
EndBatch flushes a batch of messages. If force is set, the batch will be flushed immediately instead of interleaving with other batches.
func (*Writer) Flush ¶ added in v0.3.0
Flush forces all buffered writes to be flushed. Partial batch data will be flushed as well.
func (*Writer) StartBatch ¶
StartBatch starts a batch of messages. Caller should call EndBatch to flush the buffer.