Trait EventStore

Source
pub trait EventStore<A: Aggregate>: Send + Sync {
    // Required methods
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 A::Id,
        expected_version: i64,
        events: Vec<A::Event>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent<A::Event>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 A::Id,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent<A::Event>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_from<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 A::Id,
        version: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent<A::Event>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_raw<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 A::Id,
        version: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RawStoredEvent>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

The trait for event stores.

Required Methods§

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 A::Id, expected_version: i64, events: Vec<A::Event>, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent<A::Event>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Appends a list of events to the event store for a given aggregate.

This operation must be atomic. It should fail if the expected_version does not match the current version of the aggregate, preventing optimistic concurrency conflicts.

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 A::Id, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent<A::Event>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads the full event stream for a given aggregate.

Source

fn load_from<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 A::Id, version: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent<A::Event>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads the event stream for a given aggregate starting from a specific version. This is used to hydrate an aggregate after loading it from a snapshot.

Source

fn load_raw<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 A::Id, version: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<RawStoredEvent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads the raw event stream for a given aggregate.

This is used by the GenericRepository to perform upcasting before deserializing the events.

Implementors§