wal

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	ID        string                 `json:"id"`
	Type      EntryType              `json:"type"`
	Timestamp time.Time              `json:"timestamp"`
	Version   string                 `json:"version,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
	Metadata  map[string]string      `json:"metadata,omitempty"`
	Checksum  string                 `json:"checksum"`
	Status    string                 `json:"status"` // pending, committed, rolled_back
}

Entry represents a single WAL entry

type EntryType

type EntryType string

EntryType defines types of WAL entries

const (
	EntryTypeSave     EntryType = "save"
	EntryTypeDelete   EntryType = "delete"
	EntryTypeRollback EntryType = "rollback"
	EntryTypeSnapshot EntryType = "snapshot"
	EntryTypeSeal     EntryType = "seal"
)

type WAL

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

WAL implements write-ahead logging for atomic operations

func NewWAL

func NewWAL(opts *WALOptions) (*WAL, error)

NewWAL creates a new Write-Ahead Log

func (*WAL) Append

func (w *WAL) Append(entryType EntryType, version string, data map[string]interface{}, metadata map[string]string) (*Entry, error)

Append appends a new entry to the WAL

func (*WAL) Clear

func (w *WAL) Clear() error

Clear clears all WAL entries

func (*WAL) Close

func (w *WAL) Close() error

Close closes the WAL

func (*WAL) Commit

func (w *WAL) Commit(id string) error

Commit marks an entry as committed

func (*WAL) Compact

func (w *WAL) Compact() error

Compact compacts the WAL by removing old committed entries

func (*WAL) Get

func (w *WAL) Get(id string) (*Entry, error)

Get retrieves an entry by ID

func (*WAL) GetLatestLSN

func (w *WAL) GetLatestLSN() int64

GetLatestLSN returns the latest log sequence number

func (*WAL) GetStats

func (w *WAL) GetStats() map[string]int64

GetStats returns WAL statistics

func (*WAL) List

func (w *WAL) List(entryType EntryType, status string) []*Entry

List lists all entries (optionally filtered by type or status)

func (*WAL) ListCommitted

func (w *WAL) ListCommitted() []*Entry

ListCommitted returns all committed entries

func (*WAL) ListPending

func (w *WAL) ListPending() []*Entry

ListPending returns all pending entries

func (*WAL) Recover

func (w *WAL) Recover(handler func(entry *Entry) error) error

Recover replays committed entries for recovery

func (*WAL) Rollback

func (w *WAL) Rollback(id string) error

Rollback marks an entry as rolled back

type WALOptions

type WALOptions struct {
	BasePath    string
	MaxEntries  int
	SyncOnWrite bool
}

WALOptions for configuring the WAL

func DefaultWALOptions

func DefaultWALOptions() *WALOptions

DefaultWALOptions returns default WAL options

Jump to

Keyboard shortcuts

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