pub struct Durable { /* private fields */ }Expand description
The durability façade: the single writer’s view of the store.
Implementations§
Source§impl Durable
impl Durable
pub fn new( store: SharedStore, prefix: &str, instance: &str, policy: Policy, log: Option<Logger>, ) -> Durable
pub fn store_kind(&self) -> &'static str
pub fn instance(&self) -> &str
pub fn prefix(&self) -> &str
pub fn key(&self, kind: Kind, id: &str) -> String
Sourcepub fn is_degraded(&self) -> bool
pub fn is_degraded(&self) -> bool
Whether the store has failed persistently and the policy chose to go on.
pub fn policy(&self) -> &Policy
Sourcepub fn put(
&self,
kind: Kind,
id: &str,
state: Value,
hash: Option<String>,
) -> Result<u64, StoreError>
pub fn put( &self, kind: Kind, id: &str, state: Value, hash: Option<String>, ) -> Result<u64, StoreError>
Write an entity: allocates the next seq for its key, CAS-puts the
envelope, indexes it in the manifest (debounced flush). A conflict on a
key this instance already owns is fatal (StoreError::Conflict); on a
key first seen now, the stored seq is adopted once (a restore gap).
Sourcepub fn get(&self, kind: Kind, id: &str) -> Result<Option<Envelope>, StoreError>
pub fn get(&self, kind: Kind, id: &str) -> Result<Option<Envelope>, StoreError>
The latest envelope of an entity (tombstones read as absent).
Sourcepub fn delete(&self, kind: Kind, id: &str) -> Result<(), StoreError>
pub fn delete(&self, kind: Kind, id: &str) -> Result<(), StoreError>
Remove an entity: delete when the store supports it, else a tombstone
(a put with state: null); drops it from the manifest index.
Sourcepub fn list(&self, kind: Kind) -> Result<Vec<KeySeq>, StoreError>
pub fn list(&self, kind: Kind) -> Result<Vec<KeySeq>, StoreError>
The store’s list for a kind (optional).
Sourcepub fn inbox_put(&self, ev: &InboxEvent) -> Result<u64, StoreError>
pub fn inbox_put(&self, ev: &InboxEvent) -> Result<u64, StoreError>
Write-ahead an event (before it is acted on / acknowledged).
Sourcepub fn inbox_done(&self, id: &str) -> Result<(), StoreError>
pub fn inbox_done(&self, id: &str) -> Result<(), StoreError>
Mark an event processed: deleted (or tombstoned) — it will not replay.
pub fn timer_arm(&self, t: &TimerRecord) -> Result<u64, StoreError>
pub fn timer_disarm(&self, id: &str) -> Result<(), StoreError>
pub fn manifest(&self) -> Manifest
Sourcepub fn manifest_update(&self, f: impl FnOnce(&mut Manifest))
pub fn manifest_update(&self, f: impl FnOnce(&mut Manifest))
Mutate the manifest (start-node state, budget counters, lifecycle) — flushed debounced.
Sourcepub fn flush(&self, force: bool) -> Result<bool, StoreError>
pub fn flush(&self, force: bool) -> Result<bool, StoreError>
Flush the manifest if dirty and (forced or the debounce elapsed).
Sourcepub fn restore(&self) -> Result<Restored, StoreError>
pub fn restore(&self) -> Result<Restored, StoreError>
The restore protocol (RFC 0025 §6): read the manifest, then every indexed
entity (verifying envelopes), reconcile with list where supported, warm
the seq map, bump the generation. A fresh instance (no manifest) writes
generation 1.