wal

package
v0.0.0-...-57be261 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 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

type Creator func() (DeletableWAL, error)

Creator creates a DeletableWAL. Returns an error upon failure.

type DeletableWAL

type DeletableWAL interface {
	simplex.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

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

func NewGarbageCollectedWAL

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

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

func (*GarbageCollectedWAL) ReadAll

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

func (*GarbageCollectedWAL) Truncate

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

type InMemWAL

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

func NewMemWAL

func NewMemWAL(t *testing.T) *InMemWAL

func (*InMemWAL) Append

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

func (*InMemWAL) Close

func (wal *InMemWAL) Close() error

func (*InMemWAL) ReadAll

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

type LastRecordStoringWAL

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

func NewLastRecordStoringWAL

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

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

func (*LastRecordStoringWAL) LastRecord

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

func (*LastRecordStoringWAL) Truncate

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

type Reader

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

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

type TruncateableWAL

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

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