modulepackage
0.2.1
Repository: https://github.com/siderolabs/go-circular.git
Documentation: pkg.go.dev
# README
go-circular
Package circular provides a buffer with circular semantics.
Design
The buffer is split into chunks, the last chunk is not compressed and being written to, and previous chunks are compressed and immutable.
The buffer keeps a pointer to the current offset being written which is always incremented, while the index of compressed chunks keeps the initial offset of each compressed chunk and its decompressed size.
If the compressed chunk is being read, it is decompressed on the fly by the Reader.
# Packages
Package zstd compression and decompression functions.
# Functions
NewBuffer creates new Buffer with specified options.
WithInitialCapacity sets initial buffer capacity.
WithLogger sets logger for Buffer.
WithMaxCapacity sets maximum buffer capacity.
WithNumCompressedChunks sets number of compressed chunks to keep in the buffer.
WithPersistence enables buffer persistence to disk.
WithSafetyGap sets safety gap between readers and writers to avoid buffer overrun for the reader.
# Variables
ErrClosed is raised on read from closed Reader.
ErrOutOfSync is raised when reader got too much out of sync with the writer.
ErrSeekBeforeStart is raised when seek goes beyond start of the file.
# Structs
Buffer implements circular buffer with a thread-safe writer, that supports multiple readers each with its own offset.
Options defines settings for Buffer.
PersistenceOptions defines settings for Buffer persistence.
Reader implements seekable reader with local position in the Buffer which reads from the fixed part of the buffer, or performs streaming reads.
# Interfaces
Compressor implements an optional interface for chunk compression.
# Type aliases
OptionFunc allows setting Buffer options.
StreamingReader is a backwards compatible type alias.