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
use cqrs_es2::{
    CqrsFramework,
    IAggregate,
    IQueryProcessor,
};
use postgres::Client;

use crate::stores::SnapshotEventStore;

/// A convenience type for creating a CqrsFramework backed by
/// SnapshotSqlStore and using a simple metadata supplier with
/// time of commit.
pub type SnapshotCqrs<A> = CqrsFramework<A, SnapshotEventStore<A>>;

/// A convenience function for creating a CqrsFramework using a
/// snapshot store
pub fn get_snapshot_cqrs<A: IAggregate>(
    conn: Client,
    query_processor: Vec<Box<dyn IQueryProcessor<A>>>,
) -> SnapshotCqrs<A> {
    CqrsFramework::new(
        SnapshotEventStore::new(conn),
        query_processor,
    )
}