Skip to main content

Module snapshot

Module snapshot 

Source
Expand description

Opt-in periodic snapshots of in-memory server state (VM entity tables + projection caches) and a restore path that rehydrates on startup, so a restarted server comes back with its history instead of starting empty.

arete-server owns all snapshot logic. The generated runtime’s only responsibilities are (1) registering the VmContext/SlotTracker it creates via register_runtime and (2) hydrating from a restored blob via take_restored before connecting to Yellowstone. Those hooks resolve through a task-local SnapshotRuntime, so multiple servers embedded in one process cannot consume or replace each other’s snapshot state. A stack built with an older arete-macros simply never registers a VM; snapshots stay disabled with a warning.

Consistency cut: every generated VM update holds a shared snapshot barrier guard until its mutation batch has been applied by the projector. Snapshot capture takes the exclusive guard before dumping either side, so the VM, projection caches, and resume watermark all describe the same processing cut. On restore the stream replays from that watermark; the snapshotted version trackers drop the overlap.

Re-exports§

pub use envelope::SnapshotContract;
pub use envelope::SnapshotHeader;
pub use envelope::SnapshotPayload;
pub use store::FsStore;
pub use store::SnapshotStore;

Modules§

envelope
On-disk snapshot format: a JSON header (readable with head/jq after skipping 12 bytes) followed by a zstd-compressed JSON payload.
store
Pluggable snapshot blob storage.

Structs§

RestoredState
VM state handed from the restore path to the generated runtime, consumed exactly once via take_restored.
SnapshotBarrier
Per-runtime barrier that keeps snapshot capture from splitting a VM update from the projection batch it produced.
SnapshotConfig
Configuration for state snapshots. Disabled by default; enable via ServerBuilder::snapshots(...) or ARETE_SNAPSHOT_* env vars.
SnapshotProcessingGuard
Shared processing guard carried by a mutation batch until projection is complete. The inner guard is intentionally opaque outside arete-server.
SnapshotRuntime
Per-server snapshot coordination shared by its parser, projector, snapshot manager, and readiness endpoint.
SnapshotService
Owns the store plus everything needed to dump and restore state. Created by Runtime::run when snapshots are enabled.

Enums§

ReconnectPosition
Where the generated Yellowstone runtime should resume its stream.
SnapshotTrigger
What kicked off a snapshot cycle.

Functions§

register_runtime
Called by the generated runtime after it creates its VmContext and SlotTracker, so the snapshot manager can dump them later.
take_restored
Called by the generated runtime before connecting: returns the restored VM state (if any) exactly once.