[][src]Trait eventually_core::aggregate::Aggregate

pub trait Aggregate {
    type State: Identifiable;
    type Event;
    type Command;
    type Error;
    fn apply(
        state: Self::State,
        event: Self::Event
    ) -> Result<Self::State, Self::Error>;
fn handle<'a, 's: 'a>(
        &'a self,
        state: &'s Self::State,
        command: Self::Command
    ) -> BoxFuture<'a, Result<Vec<Self::Event>, Self::Error>>
    where
        Self: Sized
; }

An Aggregate manages a domain entity State, acting as a transaction boundary.

It allows state mutations through the use of Commands, which the Aggregate instance handles and emits a number of Domain Events.

Associated Types

type State: Identifiable

State of the Aggregate: this should represent the Domain Entity data structure.

type Event

Represents a specific, domain-related change to the Aggregate State.

type Command

Commands are all the possible operations available on an Aggregate. Use Commands to model business use-cases or State mutations.

type Error

Possible failures while applying Events or handling Commands.

Loading content...

Required methods

fn apply(
    state: Self::State,
    event: Self::Event
) -> Result<Self::State, Self::Error>

Applies an Event to the current Aggregate State.

To enforce immutability, this method takes ownership of the previous State and the current Event to apply, and returns the new version of the State or an error.

fn handle<'a, 's: 'a>(
    &'a self,
    state: &'s Self::State,
    command: Self::Command
) -> BoxFuture<'a, Result<Vec<Self::Event>, Self::Error>> where
    Self: Sized

Handles the requested Command and returns a list of Events to apply the State mutation based on the current representation of the State.

Loading content...

Implementations on Foreign Types

impl<T> Aggregate for Arc<T> where
    T: Aggregate
[src]

type State = T::State

type Event = T::Event

type Command = T::Command

type Error = T::Error

Loading content...

Implementors

Loading content...