1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use cqrs_es::{Aggregate, CqrsFramework, DomainEvent, QueryProcessor};
use postgres::Connection;
use crate::{PostgresStore, PostgresStoreAggregateContext};
use crate::aggregate_store::{PostgresSnapshotStore, PostgresSnapshotStoreAggregateContext};
pub type PostgresCqrs<A, E> = CqrsFramework<A, E, PostgresStore<A, E>, PostgresStoreAggregateContext<A>>;
pub type PostgresSnapshotCqrs<A, E> = CqrsFramework<A, E, PostgresSnapshotStore<A, E>, PostgresSnapshotStoreAggregateContext<A>>;
pub fn postgres_cqrs<A, E>(conn: Connection, query_processor: Vec<Box<dyn QueryProcessor<A, E>>>) -> PostgresCqrs<A, E>
where A: Aggregate,
E: DomainEvent<A>
{
let store = PostgresStore::new(conn);
CqrsFramework::new(store, query_processor)
}
pub fn postgres_snapshot_cqrs<A, E>(conn: Connection, query_processor: Vec<Box<dyn QueryProcessor<A, E>>>) -> PostgresSnapshotCqrs<A, E>
where A: Aggregate,
E: DomainEvent<A>
{
let store = PostgresSnapshotStore::new(conn);
CqrsFramework::new(store, query_processor)
}