persist

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpType

type OpType uint8

OpType is the type of WAL operation.

const (
	OpCreateNode OpType = iota + 1
	OpCreateEdge
	OpDeleteNode
	OpDeleteEdge
	OpSetProperty
)

type Persister

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

Persister manages WAL and snapshots via Pebble.

func Open

func Open(path string) (*Persister, error)

Open creates a new Persister backed by Pebble at the given path.

func (*Persister) Close

func (p *Persister) Close() error

Close closes the Pebble database.

func (*Persister) LogCreateEdge

func (p *Persister) LogCreateEdge(edgeType, fromKey, toKey string, props map[string]any) error

LogCreateEdge appends a CreateEdge operation to the WAL.

func (*Persister) LogCreateNode

func (p *Persister) LogCreateNode(label, key string, props map[string]any) error

LogCreateNode appends a CreateNode operation to the WAL.

func (*Persister) LogDeleteNode

func (p *Persister) LogDeleteNode(key string) error

LogDeleteNode appends a DeleteNode operation to the WAL.

func (*Persister) LogSetProperty

func (p *Persister) LogSetProperty(key, propName string, propVal any) error

LogSetProperty appends a SetProperty operation to the WAL.

func (*Persister) Recover

func (p *Persister) Recover(s *schema.Schema) (*graph.Graph, error)

Recover loads the latest snapshot and replays WAL entries to rebuild the graph.

func (*Persister) TakeSnapshot

func (p *Persister) TakeSnapshot(g *graph.Graph) error

TakeSnapshot writes the current graph state to Pebble.

func (*Persister) WAL

func (p *Persister) WAL() *WAL

WAL returns the write-ahead log.

type WAL

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

WAL is a write-ahead log backed by Pebble.

func (*WAL) Append

func (w *WAL) Append(entry WALEntry) error

Append writes a WAL entry to Pebble.

func (*WAL) CurrentSeq

func (w *WAL) CurrentSeq() uint64

CurrentSeq returns the current sequence number.

func (*WAL) DeleteBefore

func (w *WAL) DeleteBefore(beforeSeq uint64) error

DeleteBefore removes all WAL entries with sequence <= beforeSeq.

func (*WAL) EntriesAfter

func (w *WAL) EntriesAfter(afterSeq uint64) ([]WALEntry, error)

EntriesAfter returns all WAL entries with sequence > afterSeq.

type WALEntry

type WALEntry struct {
	Seq      uint64         `json:"seq"`
	Op       OpType         `json:"op"`
	Label    string         `json:"label,omitempty"`
	Key      string         `json:"key,omitempty"`
	EdgeType string         `json:"edge_type,omitempty"`
	FromKey  string         `json:"from_key,omitempty"`
	ToKey    string         `json:"to_key,omitempty"`
	PropName string         `json:"prop_name,omitempty"`
	PropVal  any            `json:"prop_val,omitempty"`
	Props    map[string]any `json:"props,omitempty"`
}

WALEntry represents a single mutation in the write-ahead log.

Jump to

Keyboard shortcuts

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