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
65
66
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
#![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 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 prepare statement")]
PrepareStmt(#[source] tokio_postgres::Error),
#[error("Cannot start transaction")]
StartTx(#[source] tokio_postgres::Error),
#[error("Cannot commit transaction")]
CommitTx(#[source] tokio_postgres::Error),
#[error("Cannot execute statement")]
ExecuteStmt(#[source] tokio_postgres::Error),
#[error("Cannot convert events to bytes")]
ToBytes(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("Cannot convert bytes to events")]
FromBytes(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("Cannot get next row")]
NextRow(#[source] tokio_postgres::Error),
}