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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
#![feature(nonzero_min_max)]
#![feature(return_position_impl_trait_in_trait)]
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::TrySeqNoFromZero;
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] TrySeqNoFromZero),
}