wal

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Path       string
	BufferSize int64
	Reset      bool
}

Options wal options to create new WAL. WAL logs uses cyclic rotation to avoid fragmentation. It allocates free blocks only when log reaches target size.

type Reader

type Reader struct {
	Id uid.LID
	// contains filtered or unexported fields
}

Reader reads logs from WAL. Reader reader is a simple iterator over log data.

func (*Reader) Count

func (r *Reader) Count() uint32

Count returns entry count for the current interation.

func (*Reader) Iterator

func (r *Reader) Iterator(f func(timeID int64) (bool, error)) (err error)

Iterator iterates the pending logs from the WAL.

func (*Reader) Next

func (r *Reader) Next() ([]byte, bool, error)

Next returns next record from the iterator or false if iteration is done.

type WAL

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

WAL write ahead logs to recover db commit failure dues to db crash or other unexpected errors.

func New

func New(opts Options) (*WAL, error)

New will open a WAL. If the previous run did not shut down cleanly, a set of log entries will be returned which got committed successfully to the WAL, but were never signaled as fully completed.

If no WAL exists, a new one will be created.

func (*WAL) Close

func (wal *WAL) Close() error

Close closes the wal, frees used resources and checks for active logs.

func (*WAL) NewReader

func (wal *WAL) NewReader() (*Reader, error)

NewReader returns new log reader to read the logs from the WAL.

func (*WAL) NewWriter

func (wal *WAL) NewWriter() (*Writer, error)

NewWriter returns new log writer to write to WAL.

func (*WAL) Reset

func (wal *WAL) Reset()

Reset removes all persistested logs from log store.

func (*WAL) SignalLogApplied

func (wal *WAL) SignalLogApplied(timeID int64) error

SignalLogApplied informs the WAL that it is safe to reuse blocks.

type WALInfo

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

WALInfo provides WAL stats.

type Writer

type Writer struct {
	Id uid.LID
	// contains filtered or unexported fields
}

Writer writes entries to the write ahead log. Thread-safe.

func (*Writer) Append

func (w *Writer) Append(data []byte) <-chan error

Append appends records to the WAL.

func (*Writer) SignalInitWrite

func (w *Writer) SignalInitWrite(timeID int64) <-chan error

SignalInitWrite will signal to the WAL that log append has completed, and that the WAL can safely write log and being applied atomically.

Jump to

Keyboard shortcuts

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