Skip to main content

RunStore

Trait RunStore 

Source
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<Value>,
    ) -> BoxFuture<'a, StoreResult<()>>;
    fn events<'a>(
        &'a self,
        run_id: &'a str,
        from: u64,
    ) -> BoxFuture<'a, StoreResult<Vec<Value>>>;
    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§

Source

fn create(&self, record: RunRecord) -> BoxFuture<'_, StoreResult<()>>

Insert a new record. Fails with StoreError::Conflict if the id exists.

Source

fn put(&self, record: RunRecord) -> BoxFuture<'_, StoreResult<()>>

Insert or replace a record.

Source

fn get<'a>( &'a self, run_id: &'a str, ) -> BoxFuture<'a, StoreResult<Option<RunRecord>>>

Source

fn list(&self, filter: RunFilter) -> BoxFuture<'_, StoreResult<RunPage>>

Source

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.

Source

fn append_events<'a>( &'a self, run_id: &'a str, events: Vec<Value>, ) -> BoxFuture<'a, StoreResult<()>>

Append events (already serialized, secrets masked). Stores may cap the number of events kept per run; they then set events_truncated.

Source

fn events<'a>( &'a self, run_id: &'a str, from: u64, ) -> BoxFuture<'a, StoreResult<Vec<Value>>>

Stored events, starting at index from.

Source

fn save_snapshot<'a>( &'a self, run_id: &'a str, snapshot: &'a Snapshot, ) -> BoxFuture<'a, StoreResult<()>>

Source

fn load_snapshot<'a>( &'a self, run_id: &'a str, ) -> BoxFuture<'a, StoreResult<Option<Snapshot>>>

Source

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).

Source

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.

Source

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".

Implementors§