Skip to main content

RunStore

Trait RunStore 

Source
pub trait RunStore: Send + Sync {
    // Required methods
    fn create_run<'life0, 'async_trait>(
        &'life0 self,
        record: RunRecord,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_run<'life0, 'async_trait>(
        &'life0 self,
        run_id: RunId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn update_run_status<'life0, 'async_trait>(
        &'life0 self,
        run_id: RunId,
        status: RunStatus,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn append_event<'life0, 'async_trait>(
        &'life0 self,
        record: RunEventRecord,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn list_events<'life0, 'async_trait>(
        &'life0 self,
        run_id: RunId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RunEventRecord>, RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn list_runs<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RunRecord>, RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn delete_run<'life0, 'async_trait>(
        &'life0 self,
        run_id: RunId,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn get_run_state<'life0, 'async_trait>(
        &'life0 self,
        run_id: RunId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RunState>, RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn list_runs_filtered<'life0, 'async_trait>(
        &'life0 self,
        session_id: Option<Uuid>,
        status: Option<RunStatus>,
        limit: usize,
        offset: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RunRecord>, RuntimeError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Store for run lifecycle and events.

Implementations provide persistence for run metadata and the event-sourced event log. Default implementations are provided for get_run_state and list_runs_filtered, which backends may override with native projections for efficiency.

Required Methods§

Source

fn create_run<'life0, 'async_trait>( &'life0 self, record: RunRecord, ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Persists a new run record.

§Errors

Returns RuntimeError::Storage on persistence failure.

Source

fn get_run<'life0, 'async_trait>( &'life0 self, run_id: RunId, ) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Loads a run record by its identifier.

Returns None when no run with the given ID exists.

§Errors

Returns RuntimeError::Storage on persistence failure.

Source

fn update_run_status<'life0, 'async_trait>( &'life0 self, run_id: RunId, status: RunStatus, ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Updates the status of an existing run.

§Errors

Returns RuntimeError::Storage on persistence failure.

Source

fn append_event<'life0, 'async_trait>( &'life0 self, record: RunEventRecord, ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Appends an event to a run’s event log.

The event is stored as a RunEventRecord with a monotonically increasing sequence number.

§Errors

Returns RuntimeError::Storage on persistence failure.

Source

fn list_events<'life0, 'async_trait>( &'life0 self, run_id: RunId, ) -> Pin<Box<dyn Future<Output = Result<Vec<RunEventRecord>, RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Returns the full event log for a run, ordered by sequence number.

§Errors

Returns RuntimeError::RunNotFound when the run does not exist, or RuntimeError::Storage on persistence failure.

Source

fn list_runs<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<RunRecord>, RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Lists all runs belonging to a session.

§Errors

Returns RuntimeError::Storage on persistence failure.

Source

fn delete_run<'life0, 'async_trait>( &'life0 self, run_id: RunId, ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Deletes a run and all its associated events.

§Errors

Returns RuntimeError::Storage on persistence failure.

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Performs a health check against the underlying storage backend.

§Errors

Returns RuntimeError::Storage when the backend is unhealthy.

Provided Methods§

Source

fn get_run_state<'life0, 'async_trait>( &'life0 self, run_id: RunId, ) -> Pin<Box<dyn Future<Output = Result<Option<RunState>, RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Gets the event-sourced state of a run by replaying its event log.

Default implementation calls Self::get_run + Self::list_events and folds them into a RunState. Backends may override with a native projection for better performance.

Source

fn list_runs_filtered<'life0, 'async_trait>( &'life0 self, session_id: Option<Uuid>, status: Option<RunStatus>, limit: usize, offset: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<RunRecord>, RuntimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Lists runs with optional filters and pagination.

Default implementation iterates all sessions; backends should override with a native query for efficiency.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§