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:
- Apply events to state, producing new state.
- 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
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>>
state: &Self::State,
cmd: Self::Command
) -> Result<Vec<Self::Event>>