Trait eventsourcing::Aggregate[][src]

pub trait Aggregate {
    type Event: Event;
    type Command;
    type State: AggregateState;
    fn apply_event(state: &Self::State, evt: Self::Event) -> Result<Self::State>;
fn handle_command(
        state: &Self::State,
        cmd: Self::Command
    ) -> Result<Vec<Self::Event>>; }

An aggregate is where the vast majority of business logic for an event sourcing system occurs. They have two roles:

  1. Apply events to state, producing new state.
  2. Handle commands, producing a vector of outbound events, likely candidates for publication.

Both of these functions are stateless, as aggregates should also be stateless.

Associated Types

Required Methods

Implementors