Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBufferClosed = errors.New("buffer is closed")
ErrBufferClosed is an error to indicate an operation was attempt on a buffer after it was closed
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer interface { // Add adds an entry onto the buffer. // Is a blocking call if the buffer is full Add(context.Context, *entry.Entry) error // Read reads from the buffer. // Read can be a blocking call depending on the underlying implementation. Read(context.Context) ([]*entry.Entry, error) // Close runs cleanup code for buffer and may return entries left in the buffer // depending on the underlying implementation Close() ([]*entry.Entry, error) }
Buffer is an interface for an entry buffer
type Config ¶
type Config struct {
Builder
}
Config is a struct that wraps a Builder
func (Config) MarshalJSON ¶
func (Config) MarshalYAML ¶
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON
func (*Config) UnmarshalYAML ¶
UnmarshalYAML unmarshals YAML
type DiskBuffer ¶
type DiskBuffer struct { }
TODO add comment
func (*DiskBuffer) Add ¶
Add adds an entry onto the buffer. Is a blocking call if the buffer is full
type DiskBufferConfig ¶
type DiskBufferConfig struct { Type string `json:"type" yaml:"type"` // MaxSize is the maximum size in bytes of the data file on disk MaxSize helper.ByteSize `json:"max_size" yaml:"max_size"` // Path is a path to a directory which contains the data and metadata files Path string `json:"path" yaml:"path"` // Sync indicates whether to open the files with O_SYNC. If this is set to false, // in cases like power failures or unclean shutdowns, logs may be lost or the // database may become corrupted. Sync bool `json:"sync" yaml:"sync"` MaxChunkDelay helper.Duration `json:"max_delay" yaml:"max_delay"` MaxChunkSize uint `json:"max_chunk_size" yaml:"max_chunk_size"` }
DiskBufferConfig is a configuration struct for a DiskBuffer
func NewDiskBufferConfig ¶
func NewDiskBufferConfig() *DiskBufferConfig
NewDiskBufferConfig creates a new default disk buffer config
func (DiskBufferConfig) Build ¶
func (c DiskBufferConfig) Build() (Buffer, error)
Build creates a new Buffer from a DiskBufferConfig
type MemoryBuffer ¶
type MemoryBuffer struct {
// contains filtered or unexported fields
}
MemoryBuffer is a buffer that holds all entries in memory until Close() is called.
func (*MemoryBuffer) Add ¶
Add adds an entry onto the buffer. Is a blocking call if the buffer is full
type MemoryBufferConfig ¶
type MemoryBufferConfig struct { Type string `json:"type" yaml:"type"` MaxEntries int `json:"max_entries" yaml:"max_entries"` MaxChunkDelay helper.Duration `json:"max_delay" yaml:"max_delay"` MaxChunkSize uint `json:"max_chunk_size" yaml:"max_chunk_size"` }
MemoryBufferConfig holds the configuration for a memory buffer
func NewMemoryBufferConfig ¶
func NewMemoryBufferConfig() *MemoryBufferConfig
NewMemoryBufferConfig creates a new default MemoryBufferConfig
func (MemoryBufferConfig) Build ¶
func (c MemoryBufferConfig) Build() (Buffer, error)
Build builds a MemoryBufferConfig into a Buffer