[][src]Trait krill::commons::eventsourcing::AggregateStore

pub trait AggregateStore<A: Aggregate>: Send + Sync where
    A::Error: From<AggregateStoreError>, 
{ fn get_latest(&self, id: &Handle) -> Result<Arc<A>, AggregateStoreError>;
fn add(&self, init: A::InitEvent) -> Result<Arc<A>, AggregateStoreError>;
fn command(&self, cmd: A::Command) -> Result<Arc<A>, A::Error>;
fn has(&self, id: &Handle) -> bool;
fn list(&self) -> Vec<Handle>;
fn add_listener<L: EventListener<A>>(&mut self, listener: Arc<L>);
fn history(
        &self,
        id: &Handle
    ) -> Result<AggregateHistory<A>, AggregateStoreError>; }

Required methods

fn get_latest(&self, id: &Handle) -> Result<Arc<A>, AggregateStoreError>

Gets the latest version for the given aggregate. Returns an AggregateStoreError::UnknownAggregate in case the aggregate does not exist.

fn add(&self, init: A::InitEvent) -> Result<Arc<A>, AggregateStoreError>

Adds a new aggregate instance based on the init event.

fn command(&self, cmd: A::Command) -> Result<Arc<A>, A::Error>

Sends a command to the appropriate aggregate, and on success: save command and events, return aggregate no-op: do not save any thing, return aggregate error: save command and error, return error

fn has(&self, id: &Handle) -> bool

Returns true if an instance exists for the id

fn list(&self) -> Vec<Handle>

Lists all known ids.

fn add_listener<L: EventListener<A>>(&mut self, listener: Arc<L>)

Adds a listener that will receive a reference to all events as they are stored.

fn history(
    &self,
    id: &Handle
) -> Result<AggregateHistory<A>, AggregateStoreError>

Lists the complete history for an aggregate.

Loading content...

Implementors

impl<A: Aggregate> AggregateStore<A> for DiskAggregateStore<A> where
    A::Error: From<AggregateStoreError>, 
[src]

Loading content...