wal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpSet        = byte(0)
	OpDelete     = byte(1)
	OpSetPointer = byte(2)
)

Variables

View Source
var ErrCorrupt = errors.New("wal: corrupt record")
View Source
var ErrRecordTooLarge = errors.New("wal: record too large")

Functions

This section is empty.

Types

type Options

type Options struct {
	// MaxSegmentSize bounds the total WAL segment payload size (bytes).
	// 0 uses the default limit; values < 0 disable the cap.
	MaxSegmentSize int64
}

type Reader

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

func NewReader

func NewReader(path string) (*Reader, error)

func NewReaderWithOptions

func NewReaderWithOptions(path string, opts Options) (*Reader, error)

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) ReadNext

func (r *Reader) ReadNext() (op byte, key, val []byte, err error)

ReadNext yields the next record. It transparently handles segments.

type Record

type Record struct {
	Op    byte
	Key   []byte
	Value []byte
}

type Writer

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

func NewWriter

func NewWriter(path string) (*Writer, error)

func NewWriterWithOptions

func NewWriterWithOptions(path string, opts Options) (*Writer, error)

func (*Writer) Append

func (w *Writer) Append(op byte, key, value []byte) error

Append writes a single record as an atomic segment.

func (*Writer) AppendBatch

func (w *Writer) AppendBatch(records []Record) error

AppendBatch writes multiple records as a single atomic segment.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) RotateTo

func (w *Writer) RotateTo(path string) error

RotateTo flushes and closes the current WAL file, then opens (or creates) the provided path and reuses the writer's buffers for future appends.

func (*Writer) Size

func (w *Writer) Size() int64

func (*Writer) Sync

func (w *Writer) Sync() error

Jump to

Keyboard shortcuts

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