eventsourced_postgres/
lib.rs1mod event_log;
5mod snapshot_store;
6
7pub use event_log::{Config as PostgresEventLogConfig, PostgresEventLog};
8pub use snapshot_store::{Config as PostgresSnapshotStoreConfig, PostgresSnapshotStore};
9
10use bb8_postgres::{
11 bb8::{Pool, PooledConnection},
12 PostgresConnectionManager,
13};
14use std::num::NonZeroU64;
15use thiserror::Error;
16
17type CnnPool<T> = Pool<PostgresConnectionManager<T>>;
18
19type Cnn<'a, T> = PooledConnection<'a, PostgresConnectionManager<T>>;
20
21#[derive(Debug, Error)]
23pub enum Error {
24 #[error("Postgres error: {0}")]
26 Postgres(String, #[source] tokio_postgres::Error),
27
28 #[error("cannot get connection from pool")]
30 GetConnection(#[source] bb8_postgres::bb8::RunError<tokio_postgres::Error>),
31
32 #[error("cannot convert an event to bytes")]
34 ToBytes(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
35
36 #[error("cannot convert bytes to an event")]
38 FromBytes(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
39
40 #[error("sequence number must not be zero")]
42 ZeroNonZeroU64,
43
44 #[error("invalid last sequence number: {0:?} {1:?}")]
46 InvalidLastNonZeroU64(Option<NonZeroU64>, Option<NonZeroU64>),
47}