Struct persist_es::PersistedEventStore [−][src]
pub struct PersistedEventStore<R, A> where
R: PersistedEventRepository,
A: Aggregate + Send + Sync, { /* fields omitted */ }
Expand description
Storage engine using a database backing.
This is an event-sourced EventStore
, meaning it uses events as the
primary source of truth for the state of the aggregate.
For a snapshot-based EventStore
see PersistedSnapshotStore
.
Implementations
impl<R, A> PersistedEventStore<R, A> where
R: PersistedEventRepository,
A: Aggregate + Send + Sync,
impl<R, A> PersistedEventStore<R, A> where
R: PersistedEventRepository,
A: Aggregate + Send + Sync,
Creates a new PostgresStore
from the provided event repository,
an EventStore
used for configuring a new cqrs framework.
let repo = ...
let store = PersistedEventStore::<MyAggregate>::new(repo);
let cqrs = CqrsFramework::new(store, vec![]);
Adds configures the store to use event upcasters on load. These should be placed in the order that they are applied.
E.g., an upcaster for version 0.2.3 should be placed before an upcaster for version 0.2.4
Trait Implementations
impl<R, A> EventStore<A> for PersistedEventStore<R, A> where
R: PersistedEventRepository,
A: Aggregate + Send + Sync,
impl<R, A> EventStore<A> for PersistedEventStore<R, A> where
R: PersistedEventRepository,
A: Aggregate + Send + Sync,
type AC = EventStoreAggregateContext<A>
type AC = EventStoreAggregateContext<A>
Provides the current state of an aggregate along with surrounding context. This is used by the CqrsFramework when loading an aggregate in order to handle incoming commands. Read more
Load all events for a particular aggregate_id
fn load_aggregate<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str
) -> Pin<Box<dyn Future<Output = EventStoreAggregateContext<A>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn load_aggregate<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str
) -> Pin<Box<dyn Future<Output = EventStoreAggregateContext<A>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Load aggregate at current state
Commit new events
fn wrap_events(
&self,
aggregate_id: &str,
current_sequence: usize,
resultant_events: Vec<<A as Aggregate>::Event, Global>,
base_metadata: HashMap<String, String, RandomState>
) -> Vec<EventEnvelope<A>, Global>
fn wrap_events(
&self,
aggregate_id: &str,
current_sequence: usize,
resultant_events: Vec<<A as Aggregate>::Event, Global>,
base_metadata: HashMap<String, String, RandomState>
) -> Vec<EventEnvelope<A>, Global>
Method to wrap a set of events with the additional metadata needed for persistence and publishing