EventStoreBackend

Trait EventStoreBackend 

Source
pub trait EventStoreBackend<E: Event>: Send + Sync {
    // Required methods
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        aggregate_id: &'life1 str,
        events: Vec<E>,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_events<'life0, 'life1, 'async_trait>(
        &'life0 self,
        aggregate_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_all_events<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_events_after<'life0, 'life1, 'async_trait>(
        &'life0 self,
        aggregate_id: &'life1 str,
        version: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn save_snapshot<'life0, 'life1, 'async_trait>(
        &'life0 self,
        aggregate_id: &'life1 str,
        snapshot_data: Vec<u8>,
        version: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn get_latest_snapshot<'life0, 'life1, 'async_trait>(
        &'life0 self,
        aggregate_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, u64), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn flush<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn stats<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = BackendStats> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Available on crate feature cqrs only.
Expand description

Backend trait for event storage implementations

Required Methods§

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str, events: Vec<E>, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Append events to an aggregate’s event stream

Source

fn get_events<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all events for a specific aggregate

Source

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

Get all events from all aggregates (for projection rebuild)

Source

fn get_events_after<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str, version: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<E>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get events after a specific version (for snapshot optimization)

Provided Methods§

Source

fn save_snapshot<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str, snapshot_data: Vec<u8>, version: u64, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save a snapshot (optional, return Ok(()) if not supported)

Source

fn get_latest_snapshot<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, u64), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get latest snapshot (optional, return Err if not supported)

Source

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

Flush any pending writes (optional, for write-ahead log or batching)

Source

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

Get backend statistics

Implementors§