package bytespipe

import "github.com/dotcloud/docker/container/stream/bytespipe"

Index

Variables

var (
	// ErrClosed is returned when Write is called on a closed BytesPipe.
	ErrClosed = errors.New("write to closed BytesPipe")
)

Types

type BytesPipe

type BytesPipe struct {
	// contains filtered or unexported fields
}

BytesPipe is io.ReadWriteCloser which works similarly to pipe(queue). All written data may be read at most once. Also, BytesPipe allocates and releases new byte slices to adjust to current needs, so the buffer won't be overgrown after peak loads.

func New

func New() *BytesPipe

New creates new BytesPipe, initialized by specified slice. If buf is nil, then it will be initialized with slice which cap is 64. buf will be adjusted in a way that len(buf) == 0, cap(buf) == cap(buf).

func (*BytesPipe) Close

func (bp *BytesPipe) Close() error

Close causes further reads from a BytesPipe to return immediately.

func (*BytesPipe) CloseWithError

func (bp *BytesPipe) CloseWithError(err error) error

CloseWithError causes further reads from a BytesPipe to return immediately.

func (*BytesPipe) Read

func (bp *BytesPipe) Read(p []byte) (int, error)

Read reads bytes from BytesPipe. Data could be read only once.

func (*BytesPipe) Write

func (bp *BytesPipe) Write(p []byte) (int, error)

Write writes p to BytesPipe. It can allocate new []byte slices in a process of writing.

Source Files

buffer.go bytespipe.go

Version
v28.1.1+incompatible (latest)
Published
Apr 18, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
3 hours ago

Tools for package owners.