Skip to main content

Repository

Trait Repository 

Source
pub trait Repository: Send + Sync {
    type Aggregate: AggregateRoot;

    // Required method
    fn send<'life0, 'async_trait>(
        &'life0 self,
        cmd: <Self::Aggregate as Eventsourced>::Command,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Aggregate as Eventsourced>::Event>, PatternError<<Self::Aggregate as Eventsourced>::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Send commands to an aggregate; receive the events that resulted (or the typed domain error if the command was rejected).

Implementations are produced by CqrsPattern::builder().build().materialize() — users don’t normally implement this trait by hand.

Required Associated Types§

Source

type Aggregate: AggregateRoot

The aggregate this repository routes commands to.

Required Methods§

Source

fn send<'life0, 'async_trait>( &'life0 self, cmd: <Self::Aggregate as Eventsourced>::Command, ) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Aggregate as Eventsourced>::Event>, PatternError<<Self::Aggregate as Eventsourced>::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dispatch a command. Returns the events produced (and persisted) on success, or a PatternError wrapping the domain error / a transport / journal failure.

Implementors§