mod evt_log;
mod snapshot_store;
pub use evt_log::{Config as PostgresEvtLogConfig, PostgresEvtLog};
pub use snapshot_store::{Config as PostgresSnapshotStoreConfig, PostgresSnapshotStore};
use bb8_postgres::{
bb8::{Pool, PooledConnection},
PostgresConnectionManager,
};
use eventsourced::ZeroSeqNoError;
use thiserror::Error;
type CnnPool<T> = Pool<PostgresConnectionManager<T>>;
type Cnn<'a, T> = PooledConnection<'a, PostgresConnectionManager<T>>;
#[derive(Debug, Error)]
pub enum Error {
#[error("cannot create connection manager")]
ConnectionManager(#[source] tokio_postgres::Error),
#[error("cannot create connection pool")]
ConnectionPool(#[source] tokio_postgres::Error),
#[error("cannot get connection from pool")]
GetConnection(#[source] bb8_postgres::bb8::RunError<tokio_postgres::Error>),
#[error("cannot execute query")]
ExecuteQuery(#[source] tokio_postgres::Error),
#[error("cannot convert an event to bytes")]
ToBytes(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("cannot convert bytes to an event")]
FromBytes(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("cannot get next row")]
NextRow(#[source] tokio_postgres::Error),
#[error("cannot get column as Uuid")]
ColumnAsUuid(#[source] tokio_postgres::Error),
#[error("invalid sequence number")]
InvalidSeqNo(#[source] ZeroSeqNoError),
}