use cqrs_es::{Aggregate, CqrsFramework, QueryProcessor};
use crate::aggregate_store::{PostgresSnapshotStore, PostgresSnapshotStoreAggregateContext};
use crate::connection::Connection;
use crate::{PostgresStore, PostgresStoreAggregateContext};
pub type PostgresCqrs<A> = CqrsFramework<A, PostgresStore<A>, PostgresStoreAggregateContext<A>>;
pub type PostgresSnapshotCqrs<A> =
CqrsFramework<A, PostgresSnapshotStore<A>, PostgresSnapshotStoreAggregateContext<A>>;
pub fn postgres_cqrs<A>(
conn: Connection,
query_processor: Vec<Box<dyn QueryProcessor<A>>>,
) -> PostgresCqrs<A>
where
A: Aggregate,
{
let store = PostgresStore::new(conn);
CqrsFramework::new(store, query_processor)
}
pub fn postgres_snapshot_cqrs<A>(
conn: Connection,
query_processor: Vec<Box<dyn QueryProcessor<A>>>,
) -> PostgresSnapshotCqrs<A>
where
A: Aggregate,
{
let store = PostgresSnapshotStore::new(conn);
CqrsFramework::new(store, query_processor)
}