2022-12-14 23:48:00 +11:00
|
|
|
use tokio_postgres::config::Config as PgConfig;
|
|
|
|
use deadpool_postgres::{Manager, ManagerConfig, Pool, RecyclingMethod};
|
|
|
|
use std::error::Error;
|
|
|
|
use std::str::FromStr;
|
2022-12-18 02:30:30 +11:00
|
|
|
use uuid::Uuid;
|
2022-12-14 23:48:00 +11:00
|
|
|
use tokio_postgres::NoTls;
|
|
|
|
|
2022-12-18 02:30:30 +11:00
|
|
|
pub async fn record_listener_ping(_listener: Uuid, _pool: Pool) {
|
|
|
|
// pool.get().await?.query("");
|
|
|
|
}
|
|
|
|
|
2022-12-14 23:48:00 +11:00
|
|
|
pub fn start_pool(connstr: &str) -> Result<Pool, Box<dyn Error>> {
|
|
|
|
let mgr_config = ManagerConfig {
|
|
|
|
recycling_method: RecyclingMethod::Fast
|
|
|
|
};
|
|
|
|
let mgr = Manager::from_config(
|
|
|
|
PgConfig::from_str(connstr)?,
|
|
|
|
NoTls, mgr_config
|
|
|
|
);
|
|
|
|
|
|
|
|
Pool::builder(mgr).max_size(4).build().map_err(|e| Box::new(e) as Box<dyn Error>)
|
|
|
|
}
|