Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLimitExceeded = errors.New("Read limit exceeded")
ErrLimitExceeded signals that the underlying reader has more available bytes than the expected limit
Functions ¶
func CopyWithLimit ¶
CopyWithLimit copies props.Limit bytes from an io.Reader to an io.Writer. The copy fails if the reader has more bytes than the expected limit
Types ¶
type BiReadWriter ¶
BiReadWriter interface for wrappers that need to process bidirectional communication between two endpoints.
type LimitReader ¶
type LimitReader struct {
// contains filtered or unexported fields
}
LimitReader is an io.Reader wrapper that ensures that no more than limit bytes are read from the reader
func NewLimitReader ¶
func NewLimitReader(reader io.Reader, props ReadLimitProps) LimitReader
NewLimitReader returns a new LimitReader
type ReadLimitProps ¶
type ReadLimitProps struct { // FailOnExceed defines whether the LimitReader should return an // error if the underlying reader has more bytes than the limit FailOnExceed bool // Limit is the maximum number of bytes that can be read from the // reader and copied to the provided buffer Limit int64 // ErrOnEOF sets whether the reader should return an io.EOF error // after finishing reading the underlying source ErrOnEOF bool }
ReadLimitProps sets up the behaviour of the limit reader
type UniRead ¶
type UniRead interface { // Read processes input from the remote endpoint provided // in the reader and writes to the writer the generated // output for the remote endpoint as a response, if any Read(io.Writer, io.Reader) (int, error) }
UniRead defines an interface for unidirectional communication between a remote endpoint to the local endpoint
type UniReadFunc ¶
UniReadFunc is the implementation of UniRead for functions
type UniWrite ¶
type UniWrite interface { // Write processes input from the local endpoint provided // in the reader and writes to the writer the generated // output for the remote endpoint as a response, if any Write(io.Writer, io.Reader) (int, error) }
UniWrite defines an interface for unidirectional communication from the local endpoint to a remote endpoint
type UniWriteFunc ¶
UniWriteFunc is the implementation of UniWrite for functions