wal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogStatus

type LogStatus uint16

LogStatus represents the state of log, written to applied.

type Options

type Options struct {
	Path       string
	TargetSize int64
	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 in the current reader.

func (*Reader) Next

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

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

func (*Reader) Read

func (r *Reader) Read(f func(bool) (bool, error)) (err error)

Read reads log written to the WAL but fully applied. It returns Reader iterator.

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, bool, 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 logs from 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() error

Reset resets log file and log segments.

func (*WAL) SignalLogApplied

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

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

func (*WAL) Sync

func (wal *WAL) Sync() error

Sync syncs log entries to disk.

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(id 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