wal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WalFlags       = os.O_APPEND | os.O_CREATE | os.O_RDWR
	WalPermissions = 0666
)

Variables

View Source
var ErrInvalidCRC = errors.New("invalid CRC checksum")
View Source
var (
	ErrReadingRecord = errors.New("error reading record")
)

Functions

This section is empty.

Types

type Creator added in v0.3.0

type Creator func() (DeletableWAL, error)

Creator creates a DeletableWAL. Returns an error upon failure.

type DeletableWAL added in v0.3.0

type DeletableWAL interface {
	common.WriteAheadLog
	// Delete deletes the WAL file and after it is called,
	// it should no longer be used.
	Delete() error
}

DeletableWAL is a WAL that can be deleted.

type GarbageCollectedWAL added in v0.3.0

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

func NewGarbageCollectedWAL added in v0.3.0

func NewGarbageCollectedWAL(WALs []DeletableWAL, creator Creator, reader Reader, maxWALSize int) (*GarbageCollectedWAL, error)

NewGarbageCollectedWAL creates a new GarbageCollectedWAL. It takes in a list of existing WALs to load, a Creator to create new WALs, a Reader to read the retention term of entries, and a maximum WAL size. A new WAL is created when the given maximum WAL size of a WAL is reached.

func (*GarbageCollectedWAL) Append added in v0.3.0

func (gcw *GarbageCollectedWAL) Append(payload []byte) error

func (*GarbageCollectedWAL) Close added in v0.3.0

func (gcw *GarbageCollectedWAL) Close() error

func (*GarbageCollectedWAL) GarbageCollect added in v0.3.0

func (gcw *GarbageCollectedWAL) GarbageCollect(retentionTerm uint64) error

func (*GarbageCollectedWAL) ReadAll added in v0.3.0

func (gcw *GarbageCollectedWAL) ReadAll() ([][]byte, error)

type InMemWAL

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

func NewMemWAL

func NewMemWAL(t testing.TB) *InMemWAL

func (*InMemWAL) Append

func (wal *InMemWAL) Append(b []byte) error

func (*InMemWAL) Close added in v0.3.0

func (wal *InMemWAL) Close() error

func (*InMemWAL) ReadAll

func (wal *InMemWAL) ReadAll() ([][]byte, error)

type LastRecordStoringWAL added in v0.3.0

type LastRecordStoringWAL struct {
	TruncateableWAL
	// contains filtered or unexported fields
}

func NewLastRecordStoringWAL added in v0.3.0

func NewLastRecordStoringWAL(lastRecordFilePath string, innerWAL TruncateableWAL, recordType uint16) (*LastRecordStoringWAL, error)

NewLastRecordStoringWAL creates a new WAL that stores the last record of the given recordType. If the WAL is recentlyTruncated, the last record file is persisted to disk before the truncation takes place, and is thus saved even if the truncation removes all records of the given recordType.

func (*LastRecordStoringWAL) Append added in v0.3.0

func (ri *LastRecordStoringWAL) Append(record []byte) error

func (*LastRecordStoringWAL) LastRecord added in v0.3.0

func (ri *LastRecordStoringWAL) LastRecord() []byte

func (*LastRecordStoringWAL) Truncate added in v0.3.0

func (ri *LastRecordStoringWAL) Truncate(retentionTerm uint64) error

type Reader added in v0.3.0

type Reader interface {
	RetentionTerm([]byte) (uint64, error)
}

Reader reads the retention term of a WAL payload. Returns an error upon failure.

type TruncateableWAL added in v0.3.0

type TruncateableWAL interface {
	DeletableWAL
	Truncate(retentionTerm uint64) error
}

TruncateableWAL is a DeletableWAL that can be recentlyTruncated to a given retention term. It removes all entries below the given retention term.

type WriteAheadLog

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

func New

func New(fileName string) *WriteAheadLog

New opens a write ahead log file, creating one if necessary. Call Close() on the WriteAheadLog to ensure the file is closed after use.

func (*WriteAheadLog) Append

func (w *WriteAheadLog) Append(b []byte) error

Appends a record to the write ahead log Must flush the OS cache on every append to ensure consistency

func (*WriteAheadLog) Close

func (w *WriteAheadLog) Close() error

func (*WriteAheadLog) Delete added in v0.3.0

func (w *WriteAheadLog) Delete() error

func (*WriteAheadLog) ReadAll

func (w *WriteAheadLog) ReadAll() ([][]byte, error)

Jump to

Keyboard shortcuts

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