state

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package state owns the replicator's local watermark file.

The file lives next to the database (default: /data/.zapdb-replicate- state.json). It records the most recent badger version successfully uploaded so a restart resumes the incremental stream where it left off without re-uploading the whole DB.

It is NOT the source of truth — that is the backend's HEAD.json. The state file is just a cheap local cache that lets the daemon skip re-listing the backend on each cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(dbPath string) string

Path returns the canonical state file path for a database dir.

func Save

func Save(path string, s *State) error

Save atomically writes State to path via rename. Caller is responsible for ensuring dir exists.

Types

type State

type State struct {
	Version           int       `json:"version"` // schema version (1)
	Network           string    `json:"network"`
	LastVersion       uint64    `json:"lastVersion"`       // badger watermark we last uploaded through
	LastSnapshotKind  string    `json:"lastSnapshotKind"`  // "full" | "increment"
	LastFullVersion   uint64    `json:"lastFullVersion"`   // watermark of the most recent full snapshot
	LastFullTimestamp time.Time `json:"lastFullTimestamp"` // when the last full snapshot ran
	UpdatedAt         time.Time `json:"updatedAt"`
}

State is the persisted replicator watermark.

func Load

func Load(path string) (*State, error)

Load reads State from path. Returns a zero State (Version=1) if the file does not exist; any other error is wrapped.

Jump to

Keyboard shortcuts

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