Skip to content

Commit

Permalink
Update 'deadpool' and related databases to 0.13.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed May 23, 2024
1 parent cde1fb5 commit 091c6f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions contrib/db_pools/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ version = "0.1.0"

[dependencies.deadpool_09]
package = "deadpool"
version = "0.9"
version = "0.9.5"
default-features = false
features = ["rt_tokio_1", "managed"]
optional = true

[dependencies.deadpool-postgres]
version = "0.12"
version = "0.13.2"
default-features = false
features = ["rt_tokio_1"]
optional = true

[dependencies.deadpool]
version = "0.10"
version = "0.12.1"
default-features = false
features = ["rt_tokio_1", "managed"]
optional = true

[dependencies.deadpool-redis]
version = "0.14"
version = "0.15"
default-features = false
features = ["rt_tokio_1"]
optional = true
Expand Down
6 changes: 3 additions & 3 deletions contrib/db_pools/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@
//! Drivers have a varying degree of support for graceful shutdown, affected by
//! the `Type::init()` fairing on Rocket shutdown.
//!
//! ## `deadpool` (v0.9)
//! ## `deadpool` (v0.13)
//!
//! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
//! |----------|-----------------------------|-----------------------------|--------------------------------------|
//! | Postgres | `deadpool_postgres` (v0.12) | [`deadpool_postgres::Pool`] | [`deadpool_postgres::ClientWrapper`] |
//! | Redis | `deadpool_redis` (v0.14) | [`deadpool_redis::Pool`] | [`deadpool_redis::Connection`] |
//! | Postgres | `deadpool_postgres` (v0.13) | [`deadpool_postgres::Pool`] | [`deadpool_postgres::ClientWrapper`] |
//! | Redis | `deadpool_redis` (v0.15) | [`deadpool_redis::Pool`] | [`deadpool_redis::Connection`] |
//!
//! On shutdown, new connections are denied. Shutdown _does not_ wait for
//! connections to be returned.
Expand Down
9 changes: 4 additions & 5 deletions contrib/db_pools/lib/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ pub trait Pool: Sized + Send + Sync + 'static {

#[cfg(feature = "deadpool")]
mod deadpool_postgres {
use deadpool::{managed::{Manager, Pool, PoolError, Object, BuildError}, Runtime};
use deadpool::{Runtime, managed::{Manager, Pool, PoolError, Object}};
use super::{Duration, Error, Config, Figment};
use rocket::Either;

pub trait DeadManager: Manager + Sized + Send + Sync + 'static {
fn new(config: &Config) -> Result<Self, Self::Error>;
Expand All @@ -180,13 +179,13 @@ mod deadpool_postgres {
impl<M: DeadManager, C: From<Object<M>>> crate::Pool for Pool<M, C>
where M::Type: Send, C: Send + Sync + 'static, M::Error: std::error::Error
{
type Error = Error<Either<M::Error, BuildError>, PoolError<M::Error>>;
type Error = Error<PoolError<M::Error>>;

type Connection = C;

async fn init(figment: &Figment) -> Result<Self, Self::Error> {
let config: Config = figment.extract()?;
let manager = M::new(&config).map_err(|e| Error::Init(Either::Left(e)))?;
let manager = M::new(&config).map_err(|e| Error::Init(e.into()))?;

Pool::builder(manager)
.max_size(config.max_connections)
Expand All @@ -195,7 +194,7 @@ mod deadpool_postgres {
.recycle_timeout(config.idle_timeout.map(Duration::from_secs))
.runtime(Runtime::Tokio1)
.build()
.map_err(|e| Error::Init(Either::Right(e)))
.map_err(|_| Error::Init(PoolError::NoRuntimeSpecified))
}

async fn get(&self) -> Result<Self::Connection, Self::Error> {
Expand Down

0 comments on commit 091c6f5

Please sign in to comment.