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 std::num::NonZeroU64;
use thiserror::Error;
type CnnPool<T> = Pool<PostgresConnectionManager<T>>;
type Cnn<'a, T> = PooledConnection<'a, PostgresConnectionManager<T>>;
#[derive(Debug, Error)]
pub enum Error {
#[error("Postgres error: {0}")]
Postgres(String, #[source] tokio_postgres::Error),
#[error("cannot get connection from pool")]
GetConnection(#[source] bb8_postgres::bb8::RunError<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("sequence number must not be zero")]
ZeroNonZeroU64,
#[error("invalid last sequence number: {0:?} {1:?}")]
InvalidLastNonZeroU64(Option<NonZeroU64>, Option<NonZeroU64>),
}