Struct persist_es::PersistedSnapshotStore [−][src]
pub struct PersistedSnapshotStore<R, SR, A> where
R: PersistedEventRepository<A>,
SR: PersistedSnapshotEventRepository<A>,
A: Aggregate + Send + Sync, { /* fields omitted */ }
Expand description
Storage engine using a database backing.
This is an snapshot-sourced EventStore
, meaning it uses the serialized aggregate as the
primary source of truth for the state of the aggregate.
The individual events are also persisted but are used only for updating queries.
For a event-sourced EventStore
see PersistedEventStore
.
Implementations
impl<R, SR, A> PersistedSnapshotStore<R, SR, A> where
R: PersistedEventRepository<A>,
SR: PersistedSnapshotEventRepository<A>,
A: Aggregate + Send + Sync,
impl<R, SR, A> PersistedSnapshotStore<R, SR, A> where
R: PersistedEventRepository<A>,
SR: PersistedSnapshotEventRepository<A>,
A: Aggregate + Send + Sync,
Creates a new PostgresSnapshotStore
from the provided database connection pool,
an EventStore
used for configuring a new cqrs framework.
let store = PostgresSnapshotStore::<MyAggregate>::new(pool);
let cqrs = CqrsFramework::new(store, vec![]);
Trait Implementations
impl<R, SR, A> EventStore<A> for PersistedSnapshotStore<R, SR, A> where
R: PersistedEventRepository<A>,
SR: PersistedSnapshotEventRepository<A>,
A: Aggregate + Send + Sync,
impl<R, SR, A> EventStore<A> for PersistedSnapshotStore<R, SR, A> where
R: PersistedEventRepository<A>,
SR: PersistedSnapshotEventRepository<A>,
A: Aggregate + Send + Sync,
type AC = SnapshotStoreAggregateContext<A>
type AC = SnapshotStoreAggregateContext<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 = SnapshotStoreAggregateContext<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 = SnapshotStoreAggregateContext<A>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Load aggregate at current state
fn commit<'life0, 'async_trait>(
&'life0 self,
events: Vec<A::Event>,
context: SnapshotStoreAggregateContext<A>,
metadata: HashMap<String, String>
) -> Pin<Box<dyn Future<Output = Result<Vec<EventEnvelope<A>>, AggregateError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn commit<'life0, 'async_trait>(
&'life0 self,
events: Vec<A::Event>,
context: SnapshotStoreAggregateContext<A>,
metadata: HashMap<String, String>
) -> Pin<Box<dyn Future<Output = Result<Vec<EventEnvelope<A>>, AggregateError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
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