lineproto

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

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.

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 {

	// 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
}

func NewReader

func NewReader(r io.Reader, delim byte) *Reader

func (*Reader) ReadLine

func (r *Reader) ReadLine() ([]byte, error)

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

func (r *Reader) SetMaxLine(n int)

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.
	OnLine func(line []byte) error
	// contains filtered or unexported fields
}

Writer is safe for concurrent use.

func NewWriter

func NewWriter(w io.Writer) *Writer

func (*Writer) EndBatch

func (w *Writer) EndBatch() error

EndBatch flushes a batch of messages.

func (*Writer) Err

func (w *Writer) Err() error

func (*Writer) StartBatch

func (w *Writer) StartBatch() error

StartBatch starts a batch of messages. Caller should call EndBatch to flush the buffer.

func (*Writer) WriteLine

func (w *Writer) WriteLine(data []byte) error

WriteLine writes a single protocol message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL