Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer lets one write to some Backend and lazily create readers from it.
func New ¶
New constructs a Buffer using the underlying Backend and allowing the writer to write writeAhead extra bytes in front of the most advanced reader.
func (*Buffer) DoneReading ¶
DoneReading signals to the Buffer that no more Read calls are coming and that Write calls should return the provided error. The first call that causes both DoneReading and DoneWriting to have been called closes the underlying backend.
func (*Buffer) DoneWriting ¶
DoneWriting signals to the Buffer that no more Write calls are coming and that Read calls should return the provided error. The first call that causes both DoneReading and DoneWriting to have been called closes the underlying backend.
type ChunkBackend ¶ added in v1.13.0
type ChunkBackend struct {
// contains filtered or unexported fields
}
ChunkBackend implements the Backend interface backed by a chained series of memory-pooled slices.
func NewChunkBackend ¶ added in v1.13.0
func NewChunkBackend(cap int64) (rv *ChunkBackend)
NewChunkBackend returns a ChunkBackend with the provided initial capacity. Internally it stitchers writes together into small chunks to reduce the size of allocations needed for small objects. It implements the Backend interface. TODO: evaluate the usefulness of `cap` for the chunk backend.
func (*ChunkBackend) Close ¶ added in v1.13.0
func (u *ChunkBackend) Close() error
Close releases memory and causes future calls to ReadAt and Write to fail.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor keeps track of how many bytes have been written and the furthest advanced reader, letting one wait until space or bytes are available.
func NewCursor ¶
NewCursor constructs a new cursor that keeps track of reads and writes into some buffer, allowing one to wait until enough data has been read or written.
func (*Cursor) DoneReading ¶
DoneReading signals that no more Read calls will happen. It returns true the first time DoneWriting and DoneReading have both been called.
func (*Cursor) DoneWriting ¶
DoneWriting signals that no more Write calls will happen. It returns true the first time DoneWriting and DoneReading have both been called.
func (*Cursor) WaitRead ¶
WaitRead blocks until the writer is done or until at least n bytes have been written. It returns min(n, w.written) letting the caller know the largest offset that can be read. The ok boolean is true if there are more bytes to be read. If writing is done with an error, then 0 and that error are returned. If writing is done with no error and the requested amount is at least the amount written, it returns the written amount, false, and nil.
func (*Cursor) WaitWrite ¶
WaitWrite blocks until the readers are done or until the furthest advanced reader is within the writeAhead of the writer. It returns the largest offset that can be written. The ok boolean is true if there are readers waiting for more bytes. If reading is done with an error, then 0 and that error are returned. If reading is done with no error, then it returns the amount written, false, and nil.
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend implements the Backend interface backed by a slice.
func NewMemoryBackend ¶
func NewMemoryBackend(cap int64) (rv *MemoryBackend)
NewMemoryBackend returns a MemoryBackend with the provided initial capacity. It implements the Backend interface.
func (*MemoryBackend) Close ¶
func (u *MemoryBackend) Close() error
Close releases memory and causes future calls to ReadAt and Write to fail.