Help us shape the future of Go! Take the 2026 Go Developer Survey

commitlog

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = 1

	OpSetRID    = byte(0)
	OpSetInline = byte(1)
	OpDelete    = byte(2)
)

Variables

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

Functions

This section is empty.

Types

type Options

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

	// Compress enables best-effort zstd compression for commitlog segments.
	// Segments are only stored compressed when the compressed payload (plus a
	// small header) is smaller than the raw payload, so compression never causes
	// size amplification. Small segments are left uncompressed to avoid adding
	// hot-path CPU overhead for minimal disk savings.
	Compress bool
}

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) ReadBatch

func (r *Reader) ReadBatch() ([]Record, error)

ReadBatch reads the next batch segment.

type Record

type Record struct {
	Op    byte
	Key   []byte
	Value []byte
	RID   uint64
	Seq   uint64
}

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(record Record) error

func (*Writer) AppendBatch

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

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