wal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = wal.ErrNotFound
)

Functions

This section is empty.

Types

type Handler

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

Handler implements slog.Handler to write logs to the Binary WAL.

func NewHandler

func NewHandler(w *WAL, gen *idgen.IDGenerator, entityID uint64, entityName string, component string, opts *slog.HandlerOptions) *Handler

NewHandler creates a new WAL Handler.

func (*Handler) Enabled

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) error

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

type Options

type Options = wal.Options

Options aliases tidwall/wal.Options

type WAL

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

WAL wraps tidwall/wal with MsgPack encoding and auto-indexing.

func Open

func Open(dir string, opts *wal.Options) (*WAL, error)

Open opens a WAL at the specified directory.

func (*WAL) Close

func (w *WAL) Close() error

Close closes the log.

func (*WAL) FirstIndex

func (w *WAL) FirstIndex() (uint64, error)

FirstIndex returns the first available index.

func (*WAL) LastIndex

func (w *WAL) LastIndex() (uint64, error)

LastIndex returns the last written index.

func (*WAL) Read

func (w *WAL) Read(index uint64) ([]byte, error)

Read reads the record at the given index.

func (*WAL) Size

func (w *WAL) Size() (int64, error)

Size returns the approximate size of the WAL directory in bytes. It iterates files in the directory.

func (*WAL) TruncateFront

func (w *WAL) TruncateFront(index uint64) error

TruncateFront deletes all records before the given index.

func (*WAL) Write

func (w *WAL) Write(v interface{}) error

Write appends a value to the log. It auto-increments the index based on LastIndex + 1.

Jump to

Keyboard shortcuts

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