wal

package module
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DataSegmentSize defines the maximum size of a given Data Segment. This
	// values does not affect segments already present in the disk, if any.
	DataSegmentSize int64

	// IndexSegmentSize indicates the maximum size of the system index before
	// it is split into a next file. Each index record takes 41 bytes
	// choosing a multiple of that value will prevent index segments from
	// consuming more than it may require.
	IndexSegmentSize int64

	// WorkDir represents the absolute path to the directory where the WAL will
	// retain information. It is advised to use a directory in which only the
	// WAL instance will have access, as all files within that directory will
	// be automatically managed by the instance itself.
	WorkDir string

	// Logger allows a given stdlog.Logger instance to be set as the system
	// logger. If unset, no logs will be generated.
	Logger stdlog.Logger
}

func (Config) GetDataSegmentSize

func (c Config) GetDataSegmentSize() int64

func (Config) GetIndexSegmentSize

func (c Config) GetIndexSegmentSize() int64

func (Config) GetLogger

func (c Config) GetLogger() stdlog.Logger

func (Config) GetWorkdir

func (c Config) GetWorkdir() string

type Cursor

type Cursor interface {
	Next() bool
	Read() (io.Reader, error)
	Offset() int64
}

type WAL

type WAL interface {
	// WriteObject writes a given object to the WAL. Returns an error in case
	// the write operation fails.
	WriteObject(data []byte) error

	// ReadObject attempts to read a previously stored object under a given
	// id. Either returns an io.Reader for the object's data, or an error. In
	// case the object has been marked for removal, a NotFoundError is returned.
	ReadObject(id int64) (io.Reader, error)

	// ReadObjects returns a new Cursor pointing to either the object under the
	// specified id, or its right sibling, depending on the value of the
	// inclusive flag.
	ReadObjects(id int64, inclusive bool) Cursor

	// Close flushes all data to disk, and safely closes underlying facilities
	// of the WAL.
	Close() error

	// VacuumRecords marks and removes all records from the storage medium.
	// Whether the provided id is also included in the vacuuming is defined by
	// the inclusive flag.
	VacuumRecords(id int64, inclusive bool) error

	// CountObjects returns the amount of objects after a given id. In case the
	// inclusive flag is set, the object itself is also accounted in the
	// returned total.
	CountObjects(id int64, inclusive bool) int64

	// CurrentRecordID returns the id of the latest written object
	CurrentRecordID() int64

	// IsEmpty returns whether the WAL contains any items. Returns true in case
	// no item is currently stored, otherwise returns false.
	IsEmpty() bool

	// MinimumRecordID returns the minimum record available in the WAL. Returns
	// -1 in case no record is available.
	MinimumRecordID() int64
}

func New

func New(config Config) (WAL, error)

Directories

Path Synopsis
flock
Package flock implements a small wrapper around the flock(2) Kernel API in order to provide advisory locks through the filesystem.
Package flock implements a small wrapper around the flock(2) Kernel API in order to provide advisory locks through the filesystem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL