pub trait EventStore {
type SourceId: Eq;
type Event;
type Error: AppendError;
// Required methods
fn append(
&mut self,
source_id: Self::SourceId,
version: Expected,
events: Vec<Self::Event>,
) -> BoxFuture<'_, Result<u32, Self::Error>>;
fn stream(
&self,
source_id: Self::SourceId,
select: Select,
) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>;
fn stream_all(
&self,
select: Select,
) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>;
fn remove(
&mut self,
source_id: Self::SourceId,
) -> BoxFuture<'_, Result<(), Self::Error>>;
}Expand description
Required Associated Types§
Sourcetype SourceId: Eq
type SourceId: Eq
Type of the Source id, typically an AggregateId.
Sourcetype Event
type Event
Event to be stored in the EventStore, typically an Aggregate::Event.
Sourcetype Error: AppendError
type Error: AppendError
Possible errors returned by the EventStore when requesting operations.
Required Methods§
Sourcefn append(
&mut self,
source_id: Self::SourceId,
version: Expected,
events: Vec<Self::Event>,
) -> BoxFuture<'_, Result<u32, Self::Error>>
fn append( &mut self, source_id: Self::SourceId, version: Expected, events: Vec<Self::Event>, ) -> BoxFuture<'_, Result<u32, 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 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.
Sourcefn stream(
&self,
source_id: Self::SourceId,
select: Select,
) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>
fn stream( &self, source_id: Self::SourceId, select: Select, ) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>
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.
Sourcefn stream_all(
&self,
select: Select,
) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>
fn stream_all( &self, select: Select, ) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>
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.