wal

package module
v0.0.0-...-d9650e1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 16 Imported by: 0

README

WAL

Write Ahead Log implemented in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WAL

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

func GetWAL

func GetWAL(directory string, enableFsync bool, maxFileSize uint64, maxSegments uint) (*WAL, error)

initialises a new WAL

func (*WAL) Close

func (wal *WAL) Close() error

flushes buffers to files and closes current wal instance

func (*WAL) CreateCheckpoint

func (wal *WAL) CreateCheckpoint(data []byte) error

creates checkpoint entry in the wal useful to restore the state of system to this point

func (*WAL) Flush

func (wal *WAL) Flush() error

writes in-memory buffer to the segment file in file system if fsync is opted, syncs file to the disk

func (*WAL) ReadAllFromCurrent

func (wal *WAL) ReadAllFromCurrent(fromCheckpoint bool) ([]*types.WAL_Entry, error)

reads all entries from the wal if checkpoint is true, returns all entries after that checkpoint if no checkpoint is found, empty slice is returned

func (*WAL) ReadAllFromIndex

func (wal *WAL) ReadAllFromIndex(index int, fromCheckpoint bool) ([]*types.WAL_Entry, error)

reads segment files starting from the given segment index if checkpoint is true, returns all entries after that checkpoint if no checkpoint is found, empty slice is returned

func (*WAL) WriteEntry

func (wal *WAL) WriteEntry(data []byte) error

writes entry to wal without creating checkpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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