Expand description
Persistence for watch resume state.
StateStore is an async trait for persisting and retrieving
Checkpoints keyed by ResumeKey, consumed by the aviso
watch supervisor for at-least-once delivery across reconnects and
process restarts. Implementations are Send + Sync and serialise
concurrent writes internally so the in-memory and (where
applicable) on-disk states stay consistent.
A successful StateStore::put is committed-before-visible: a
subsequent StateStore::get returns the resolved value. For
durable implementations (such as JsonFileStore) the same
guarantee is durable-before-visible: the disk write returns
success before the new value becomes visible to readers. A failed
put leaves all state unchanged.
put is strictly monotonic in last_committed_sequence: a
put with a sequence less than or equal to the existing value is a
silent no-op. Both implementations enforce this so consumers see
identical behaviour regardless of the backing store. Callers
needing to reset a checkpoint to a lower sequence must
delete first, then put.
Two implementations are provided:
MemoryStore: in-process. State dies with the program. Good for tests and short-lived consumers.JsonFileStore: backed by a JSON file with crash-safe atomic writes via theatomicwritescrate plus a cross-process advisory lock on a sidecar lockfile. Safe for cooperating processes on local filesystems; see the type docs for the precondition list (no NFS/CIFS, no external deletion of the lockfile).
Resume keys are derived from a base URL, an event type, the watch filter body, and an optional schema fingerprint. The hash deliberately excludes any server-side resume position; the same logical subscription always computes the same key.
Structs§
- Checkpoint
- A committed position in a watch stream, keyed by
ResumeKey. - Json
File Store - File-backed state store, multi-process safe for cooperating processes on local filesystems.
- Memory
Store - In-process
StateStorebacked by aHashMapbehind a tokioRwLock. - Resume
Key - A logical identifier for a watch subscription.
Enums§
- Resume
KeyError - Errors specific to resume-key construction.
- Store
Error - Errors a
StateStoreimplementation can return.
Traits§
- State
Store - Persistent storage for
Checkpointkeyed byResumeKey.