[][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 command_history(
        &self,
        id: &Handle,
        crit: CommandHistoryCriteria
    ) -> Result<CommandHistory, AggregateStoreError>;
fn stored_command(
        &self,
        id: &Handle,
        key: &CommandKey
    ) -> Result<Option<StoredCommand<A::StorableCommandDetails>>, AggregateStoreError>;
fn stored_event(
        &self,
        id: &Handle,
        version: u64
    ) -> Result<Option<A::Event>, 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 command_history(
    &self,
    id: &Handle,
    crit: CommandHistoryCriteria
) -> Result<CommandHistory, AggregateStoreError>

Lists the history for an aggregate.

fn stored_command(
    &self,
    id: &Handle,
    key: &CommandKey
) -> Result<Option<StoredCommand<A::StorableCommandDetails>>, AggregateStoreError>

Returns a stored command if it can be found.

fn stored_event(
    &self,
    id: &Handle,
    version: u64
) -> Result<Option<A::Event>, AggregateStoreError>

Returns a stored event if it can be found.

Loading content...

Implementors

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

Loading content...