[][src]Trait eventually::EventStore

pub trait EventStore {
    type SourceId: Eq;
    type Event;
    type Error: AppendError;
    fn append(
        &mut self,
        source_id: Self::SourceId,
        version: Expected,
        events: Vec<Self::Event>
    ) -> Pin<Box<dyn Future<Output = Result<u32, Self::Error>> + Send>>;
fn stream(
        &self,
        source_id: Self::SourceId,
        select: Select
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<Self::SourceId, Self::Event>, Self::Error>> + Send>>, Self::Error>> + Send>>;
fn stream_all(
        &self,
        select: Select
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<Self::SourceId, Self::Event>, Self::Error>> + Send>>, Self::Error>> + Send>>;
fn remove(
        &mut self,
        source_id: Self::SourceId
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>>; }

An Event Store is an append-only, ordered list of Events for a certain "source" -- e.g. an Aggregate.

Associated Types

type SourceId: Eq

Type of the Source id, typically an AggregateId.

type Event

Event to be stored in the EventStore, typically an Aggregate::Event.

type Error: AppendError

Possible errors returned by the EventStore when requesting operations.

Loading content...

Required methods

fn append(
    &mut self,
    source_id: Self::SourceId,
    version: Expected,
    events: Vec<Self::Event>
) -> Pin<Box<dyn Future<Output = Result<u32, Self::Error>> + Send>>

Appends a new list of Events to the Event Store, for the Source entity specified by SourceId.

append is a transactional operation: it either appends all the events, or none at all and returns an AppendError.

The desired version for the new Events to append must be specified through an Expected element.

When using Expected::Any, no checks on the current [Aggregate] values will be performed, disregarding optimistic locking.

When using Expected::Exact, the Store will check that the current version of the [Aggregate] is exactly the one specified.

If the version is not the one expected from the Store, implementations should raise an AppendError::Conflict error.

Implementations could decide to return an error if the expected version is different from the one supplied in the method invocation.

fn stream(
    &self,
    source_id: Self::SourceId,
    select: Select
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<Self::SourceId, Self::Event>, Self::Error>> + Send>>, Self::Error>> + Send>>

Streams a list of Events from the EventStore back to the application, by specifying the desired SourceId and Select operation.

SourceId will be used to request a particular EventStream.

Select specifies the selection strategy for the Events in the returned EventStream: take a look at type documentation for all the available options.

fn stream_all(
    &self,
    select: Select
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<Self::SourceId, Self::Event>, Self::Error>> + Send>>, Self::Error>> + Send>>

Streams a list of Events from the EventStore back to the application, disregarding the SourceId values but using a Select operation.

SourceId will be used to request a particular EventStream.

Select specifies the selection strategy for the Events in the returned EventStream: take a look at type documentation for all the available options.

fn remove(
    &mut self,
    source_id: Self::SourceId
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>>

Drops all the Events related to one Source, specified by the provided SourceId.

Loading content...

Implementors

impl<Id, Event> EventStore for EventStore<Id, Event> where
    Event: Sync + Send + Debug + Clone,
    Id: Hash + Eq + Sync + Send + Debug + Clone
[src]

type SourceId = Id

type Event = Event

type Error = ConflictError

Loading content...