[][src]Trait eventually_core::store::EventStore

pub trait EventStore {
    type SourceId: Eq;
    type Offset: Ord;
    type Event;
    type Error;
    fn append(
        &mut self,
        id: Self::SourceId,
        events: Vec<Self::Event>
    ) -> BoxFuture<Result<(), Self::Error>>;
fn stream(
        &self,
        id: Self::SourceId,
        from: Self::Offset
    ) -> BoxFuture<Result<EventStream<Self>, Self::Error>>;
fn remove(
        &mut self,
        id: Self::SourceId
    ) -> BoxFuture<Result<(), Self::Error>>; }

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 Offset: Ord

Offset type for getting a slice of the Events in the Store.

Check out stream for more info.

type Event

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

type Error

Possible errors returned by the EventStore when requesting operations.

Loading content...

Required methods

fn append(
    &mut self,
    id: Self::SourceId,
    events: Vec<Self::Event>
) -> BoxFuture<Result<(), Self::Error>>

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 appropriate Error.

fn stream(
    &self,
    id: Self::SourceId,
    from: Self::Offset
) -> BoxFuture<Result<EventStream<Self>, Self::Error>>

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

SourceId will be used to request a particular EventStream.

Offset will be used to specify a slice of the Events to retrieve from the EventStore. To request the whole list, use the Default value for Offset.

fn remove(&mut self, id: Self::SourceId) -> BoxFuture<Result<(), Self::Error>>

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

Loading content...

Implementors

Loading content...