postgres_es2/framework/
postgres_cqrs.rs

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