Update 'deadpool' and related databases to 0.13.

This commit is contained in:
Sergio Benitez 2024-05-22 19:48:17 -05:00
parent cde1fb5de0
commit 091c6f58f6
3 changed files with 11 additions and 12 deletions

View File

@ -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

View File

@ -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.

View File

@ -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>;
@ -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)
@ -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> {