pub trait EventStore: StorageBackend {
// Required methods
fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
tenant_id: &'life2 TenantId,
event: ExecutionEventData,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn append_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
tenant_id: &'life2 TenantId,
events: Vec<ExecutionEventData>,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn load_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn load_events_after<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
after_seq: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_latest_sequence<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_executions<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 TenantId,
limit: usize,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<ExecutionId>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn execution_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn count_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
EventStore trait - append-only event log
This is the core persistence trait for execution events. All execution state can be reconstructed by replaying events from this store.
Required Methods§
Sourcefn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
tenant_id: &'life2 TenantId,
event: ExecutionEventData,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
tenant_id: &'life2 TenantId,
event: ExecutionEventData,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Append an event to the store
§Arguments
execution_id- The execution this event belongs totenant_id- Tenant for multi-tenancy isolationevent- The event data to store
§Returns
Ok(sequence)- The sequence number assigned to this eventErr- If the event could not be persisted
§Guarantees
- Event is durable when this returns Ok
- Sequence numbers are monotonically increasing per execution
Sourcefn append_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
tenant_id: &'life2 TenantId,
events: Vec<ExecutionEventData>,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn append_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
tenant_id: &'life2 TenantId,
events: Vec<ExecutionEventData>,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Append multiple events atomically
All events are stored with consecutive sequence numbers, or none are stored.
§Returns
Ok(first_sequence)- The sequence number of the first event in the batch
Sourcefn load_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load all events for an execution
Returns events ordered by sequence number.
Sourcefn load_events_after<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
after_seq: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_events_after<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
after_seq: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load events after a specific sequence number
Useful for incremental replay or catching up after a checkpoint.
§Arguments
execution_id- The execution to load events forafter_seq- Return events with sequence > after_seq
Sourcefn get_latest_sequence<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_latest_sequence<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the latest sequence number for an execution
Returns None if no events exist for this execution.
Sourcefn list_executions<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 TenantId,
limit: usize,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<ExecutionId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_executions<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 TenantId,
limit: usize,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<ExecutionId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List executions for a tenant
Returns execution IDs ordered by creation time (newest first).
§Arguments
tenant_id- The tenant to list executions forlimit- Maximum number of executions to returnoffset- Number of executions to skip (for pagination)
Provided Methods§
Sourcefn execution_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execution_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if an execution exists
Sourcefn count_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count_events<'life0, 'life1, 'async_trait>(
&'life0 self,
execution_id: &'life1 ExecutionId,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Count events for an execution