Expand description
Atomic JSON sidecar for _system/ state files.
Several uni-db subsystems persist a small document under
<data_path>/_system/<name>.json — the CDC checkpoint table, the deferred-
trigger queue, the background-job scheduler (in uni-plugin-host), and the
declared-plugins registry (in uni-plugin-custom). They all want the same
thing: load the whole document at startup (treating a missing or empty file
as “nothing yet”), and replace it atomically on every write. This crate is
the single, correct implementation of that pattern, shared so no subsystem
re-rolls it.
“Atomic” here means write-to-temp, fsync the temp file, then rename over
the target. Crucially it also fsyncs the parent directory after the
rename: on POSIX a rename is not crash-durable until the directory entry is
flushed, so without it a power loss can leave the file reverted to its
pre-rename contents even though the data was synced.
SystemSidecar handles only the IO. Higher-level concerns — write
serialization (a mutex spanning read-modify-write), a best-effort Cypher
mirror, per-row re-binding — stay with the callers, which compose them
around SystemSidecar::load / SystemSidecar::store.
Structs§
- System
Sidecar - Atomic JSON persistence for one
_system/document of typeT. - VecSidecar
- Atomic JSON sidecar specialized to a
Vec<T>document — the shape every_system/row table uses (CDC checkpoints, scheduler jobs, deferred triggers, declared plugins).
Enums§
- Sidecar
IoError - Error raised by
SystemSidecarload/store operations.