pub struct RunStore { /* private fields */ }Expand description
Volatile run-status cache keyed by run id, with CAS-based idempotency.
Implementations§
Source§impl RunStore
impl RunStore
Sourcepub async fn claim_idempotent(
&self,
idempotency_key: &str,
run_id: &str,
) -> Result<ClaimOutcome, StoreError>
pub async fn claim_idempotent( &self, idempotency_key: &str, run_id: &str, ) -> Result<ClaimOutcome, StoreError>
Atomically claim idempotency_key for run_id via cas(expected = None). The first caller gets ClaimOutcome::Created; a concurrent
or later identical submit reads the winner’s id
(ClaimOutcome::AlreadyExists).
Sourcepub async fn create(&self, view: &RunRecordView) -> Result<(), StoreError>
pub async fn create(&self, view: &RunRecordView) -> Result<(), StoreError>
Persist a fresh run record and mark it active.
Writes the active marker before the run record. If the process
dies between the two writes, a stray marker with no record is left
behind — Self::list_active tolerates that (skips it). The
reverse order would risk the opposite, worse failure: a Pending
record with no marker, which the sweep would silently never see.
Sourcepub async fn rollback_claim(
&self,
idempotency_key: &str,
run_id: &str,
) -> Result<(), StoreError>
pub async fn rollback_claim( &self, idempotency_key: &str, run_id: &str, ) -> Result<(), StoreError>
Undo a claim + its pending record + active marker after a post-claim failure (e.g. the run-start audit append failed), so a genuine retry with the same key re-runs instead of resolving to a dead run. Best-effort — a delete failure leaves the sweep as the backstop.
Sourcepub async fn set_running(&self, run_id: &str) -> Result<(), StoreError>
pub async fn set_running(&self, run_id: &str) -> Result<(), StoreError>
Mark the run Running.
Sourcepub async fn set_succeeded(
&self,
run_id: &str,
result: Value,
) -> Result<(), StoreError>
pub async fn set_succeeded( &self, run_id: &str, result: Value, ) -> Result<(), StoreError>
Mark the run Succeeded with its output envelope, then retire its
active marker.
Sourcepub async fn set_failed(
&self,
run_id: &str,
error: String,
) -> Result<(), StoreError>
pub async fn set_failed( &self, run_id: &str, error: String, ) -> Result<(), StoreError>
Mark the run Failed with a summary, then retire its active marker.
Sourcepub async fn set_aborted(
&self,
run_id: &str,
error: String,
) -> Result<(), StoreError>
pub async fn set_aborted( &self, run_id: &str, error: String, ) -> Result<(), StoreError>
Mark the run Aborted (timed out) with a summary, then retire its
active marker.
Sourcepub async fn get(
&self,
run_id: &str,
) -> Result<Option<RunRecordView>, StoreError>
pub async fn get( &self, run_id: &str, ) -> Result<Option<RunRecordView>, StoreError>
Read a run record, or None if unknown.