postgres_es2/framework/
postgres_snapshot_cqrs.rs

1use cqrs_es2::{
2    Aggregate,
3    CqrsFramework,
4    QueryProcessor,
5};
6use postgres::Client;
7
8use crate::aggregates::{
9    PostgresSnapshotStore,
10    PostgresSnapshotStoreAggregateContext,
11};
12
13/// A convenience type for creating a CqrsFramework backed by
14/// PostgresSnapshotStore and using a simple metadata supplier with
15/// time of commit.
16pub type PostgresSnapshotCqrs<A> = CqrsFramework<
17    A,
18    PostgresSnapshotStore<A>,
19    PostgresSnapshotStoreAggregateContext<A>,
20>;
21
22/// A convenience function for creating a CqrsFramework using a
23/// snapshot store
24pub fn postgres_snapshot_cqrs<A>(
25    conn: Client,
26    query_processor: Vec<Box<dyn QueryProcessor<A>>>,
27) -> PostgresSnapshotCqrs<A>
28where
29    A: Aggregate, {
30    let store = PostgresSnapshotStore::new(conn);
31    CqrsFramework::new(store, query_processor)
32}