diff --git a/contrib/db_pools/lib/Cargo.toml b/contrib/db_pools/lib/Cargo.toml index 80c5e40e..6d649e8a 100644 --- a/contrib/db_pools/lib/Cargo.toml +++ b/contrib/db_pools/lib/Cargo.toml @@ -34,19 +34,19 @@ path = "../codegen" version = "0.1.0-rc" [dependencies.deadpool] -version = "0.8" +version = "0.9" default-features = false features = ["rt_tokio_1", "managed"] optional = true [dependencies.deadpool-postgres] -version = "0.9" +version = "0.10" default-features = false features = ["rt_tokio_1"] optional = true [dependencies.deadpool-redis] -version = "0.8.1" +version = "0.10" default-features = false features = ["rt_tokio_1"] optional = true diff --git a/contrib/db_pools/lib/src/lib.rs b/contrib/db_pools/lib/src/lib.rs index f10b6476..b8c019c2 100644 --- a/contrib/db_pools/lib/src/lib.rs +++ b/contrib/db_pools/lib/src/lib.rs @@ -101,7 +101,7 @@ //! At present, this crate supports _three_ drivers: [`deadpool`], [`sqlx`], //! and [`mongodb`]. Each driver may support multiple databases. //! -//! ## `deadpool` (v0.8) +//! ## `deadpool` (v0.9) //! //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref | //! |----------|---------------------|-----------------------------|---------------------------------------| diff --git a/contrib/db_pools/lib/src/pool.rs b/contrib/db_pools/lib/src/pool.rs index a1ecf0b9..c067216b 100644 --- a/contrib/db_pools/lib/src/pool.rs +++ b/contrib/db_pools/lib/src/pool.rs @@ -137,7 +137,7 @@ pub trait Pool: Sized + Send + Sync + 'static { #[cfg(feature = "deadpool")] mod deadpool_postgres { - use deadpool::managed::{Manager, Pool, PoolConfig, PoolError, Object}; + use deadpool::{managed::{Manager, Pool, PoolError, Object, BuildError}, Runtime}; use super::{Duration, Error, Config, Figment}; pub trait DeadManager: Manager + Sized + Send + Sync + 'static { @@ -162,20 +162,22 @@ mod deadpool_postgres { impl>> crate::Pool for Pool where M::Type: Send, C: Send + Sync + 'static, M::Error: std::error::Error { - type Error = Error>; + type Error = Error, PoolError>; type Connection = C; async fn init(figment: &Figment) -> Result { let config: Config = figment.extract()?; - let manager = M::new(&config).map_err(Error::Init)?; + let manager = M::new(&config).map_err(|e| Error::Init(BuildError::Backend(e)))?; - let mut pool = PoolConfig::new(config.max_connections); - pool.timeouts.create = Some(Duration::from_secs(config.connect_timeout)); - pool.timeouts.wait = Some(Duration::from_secs(config.connect_timeout)); - pool.timeouts.recycle = config.idle_timeout.map(Duration::from_secs); - pool.runtime = deadpool::Runtime::Tokio1; - Ok(Pool::from_config(manager, pool)) + Pool::builder(manager) + .max_size(config.max_connections) + .wait_timeout(Some(Duration::from_secs(config.connect_timeout))) + .create_timeout(Some(Duration::from_secs(config.connect_timeout))) + .recycle_timeout(config.idle_timeout.map(Duration::from_secs)) + .runtime(Runtime::Tokio1) + .build() + .map_err(Error::Init) } async fn get(&self) -> Result {