pub trait RunStore:
Send
+ Sync
+ Debug {
// Required methods
fn create(&self, record: RunRecord) -> BoxFuture<'_, StoreResult<()>>;
fn put(&self, record: RunRecord) -> BoxFuture<'_, StoreResult<()>>;
fn get<'a>(
&'a self,
run_id: &'a str,
) -> BoxFuture<'a, StoreResult<Option<RunRecord>>>;
fn list(&self, filter: RunFilter) -> BoxFuture<'_, StoreResult<RunPage>>;
fn delete<'a>(&'a self, run_id: &'a str) -> BoxFuture<'a, StoreResult<bool>>;
fn append_events<'a>(
&'a self,
run_id: &'a str,
events: Vec<StoredEvent>,
) -> BoxFuture<'a, StoreResult<()>>;
fn events<'a>(
&'a self,
run_id: &'a str,
from: u64,
) -> BoxFuture<'a, StoreResult<Vec<StoredEvent>>>;
fn save_snapshot<'a>(
&'a self,
run_id: &'a str,
snapshot: &'a Snapshot,
) -> BoxFuture<'a, StoreResult<()>>;
fn load_snapshot<'a>(
&'a self,
run_id: &'a str,
) -> BoxFuture<'a, StoreResult<Option<Snapshot>>>;
fn claim_resume<'a>(
&'a self,
run_id: &'a str,
now_ms: u64,
) -> BoxFuture<'a, StoreResult<RunRecord>>;
fn recover_interrupted(
&self,
now_ms: u64,
) -> BoxFuture<'_, StoreResult<usize>>;
fn purge_before(&self, cutoff_ms: u64) -> BoxFuture<'_, StoreResult<usize>>;
}Expand description
Durable storage of run records, events and snapshots.
Implementations must make RunStore::claim_resume atomic: of two concurrent
claims on the same paused run, exactly one succeeds.
Required Methods§
Sourcefn create(&self, record: RunRecord) -> BoxFuture<'_, StoreResult<()>>
fn create(&self, record: RunRecord) -> BoxFuture<'_, StoreResult<()>>
Insert a new record. Fails with StoreError::Conflict if the id exists.
fn get<'a>( &'a self, run_id: &'a str, ) -> BoxFuture<'a, StoreResult<Option<RunRecord>>>
fn list(&self, filter: RunFilter) -> BoxFuture<'_, StoreResult<RunPage>>
Sourcefn delete<'a>(&'a self, run_id: &'a str) -> BoxFuture<'a, StoreResult<bool>>
fn delete<'a>(&'a self, run_id: &'a str) -> BoxFuture<'a, StoreResult<bool>>
Remove a run and everything stored for it. Returns whether it existed.
Sourcefn append_events<'a>(
&'a self,
run_id: &'a str,
events: Vec<StoredEvent>,
) -> BoxFuture<'a, StoreResult<()>>
fn append_events<'a>( &'a self, run_id: &'a str, events: Vec<StoredEvent>, ) -> BoxFuture<'a, StoreResult<()>>
Append events (already serialized by event_to_stored, secrets masked).
Stores may cap the number of events kept per run; they then set
events_truncated.
Sourcefn events<'a>(
&'a self,
run_id: &'a str,
from: u64,
) -> BoxFuture<'a, StoreResult<Vec<StoredEvent>>>
fn events<'a>( &'a self, run_id: &'a str, from: u64, ) -> BoxFuture<'a, StoreResult<Vec<StoredEvent>>>
Stored events, starting at index from.
fn save_snapshot<'a>( &'a self, run_id: &'a str, snapshot: &'a Snapshot, ) -> BoxFuture<'a, StoreResult<()>>
fn load_snapshot<'a>( &'a self, run_id: &'a str, ) -> BoxFuture<'a, StoreResult<Option<Snapshot>>>
Sourcefn claim_resume<'a>(
&'a self,
run_id: &'a str,
now_ms: u64,
) -> BoxFuture<'a, StoreResult<RunRecord>>
fn claim_resume<'a>( &'a self, run_id: &'a str, now_ms: u64, ) -> BoxFuture<'a, StoreResult<RunRecord>>
Atomically move a paused run to running and return the updated record.
Fails with StoreError::Conflict when the run is not paused (including when
another request claimed it first).
Sourcefn recover_interrupted(&self, now_ms: u64) -> BoxFuture<'_, StoreResult<usize>>
fn recover_interrupted(&self, now_ms: u64) -> BoxFuture<'_, StoreResult<usize>>
After a host restart: mark every running run as failed (“interrupted by
restart”). Paused runs stay resumable. Returns how many runs were marked.
Sourcefn purge_before(&self, cutoff_ms: u64) -> BoxFuture<'_, StoreResult<usize>>
fn purge_before(&self, cutoff_ms: u64) -> BoxFuture<'_, StoreResult<usize>>
Delete runs (any status except running) last updated before cutoff_ms.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".