Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorWriteTruncated is returned when a non-blocking write does not fit in the buffer // and was truncated ErrorWriteTruncated = errors.New("Write truncated due to full write buffer") // ErrorWriteFull is returned when a non-blocking write does not fit in the buffer // and was not performed ErrorWriteFull = errors.New("Write ignored due to full write buffer") // ErrorClosed is returned when the caller tries to write to a closed pipe, or tries to read // from a closed and empty pipe ErrorClosed = errors.New("The pipe is closed") )
Functions ¶
This section is empty.
Types ¶
type BufferedPipe ¶
type BufferedPipe struct { io.ReadWriteCloser sync.Mutex WriteAllowTruncate bool WriteBlocks bool // contains filtered or unexported fields }
BufferedPipe is an io.ReadWriteCloser. What is written via the writer comes out via the Reader. A configurable buffer is present in between. Writing behaviour can be configured both in blocking and non blocking ways.
func NewBufferedPipe ¶
func NewBufferedPipe(maximumCapacity int) *BufferedPipe
NewBufferedPipe constructs a new pipe with the stated maximum capacity. If maximumCapacity is zero or less, the capacity is not bounded.
func (*BufferedPipe) Close ¶
func (b *BufferedPipe) Close() error
Close closes the pipe. Read calls will return ErrorClosed when the pipe is exhausted. Write call will return ErrorClosed right away
func (*BufferedPipe) Len ¶
func (b *BufferedPipe) Len() int
Len returns the number of bytes currently stored in the pipe
func (*BufferedPipe) MaximumCapacity ¶
func (b *BufferedPipe) MaximumCapacity() int
MaximumCapacity returns the maximum amount of bytes that can be stored in the pipe
func (*BufferedPipe) Read ¶
func (b *BufferedPipe) Read(p []byte) (int, error)
Read implements the read function of io.Reader
func (*BufferedPipe) RemainingCapacity ¶
func (b *BufferedPipe) RemainingCapacity() int
RemainingCapacity returns the minimum amount of bytes that can be written to the pipe without blocking for truncation