mirror of https://github.com/rwf2/Rocket.git
Update 'deadpool' and related databases to 0.13.
This commit is contained in:
parent
cde1fb5de0
commit
091c6f58f6
|
@ -41,25 +41,25 @@ version = "0.1.0"
|
||||||
|
|
||||||
[dependencies.deadpool_09]
|
[dependencies.deadpool_09]
|
||||||
package = "deadpool"
|
package = "deadpool"
|
||||||
version = "0.9"
|
version = "0.9.5"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["rt_tokio_1", "managed"]
|
features = ["rt_tokio_1", "managed"]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.deadpool-postgres]
|
[dependencies.deadpool-postgres]
|
||||||
version = "0.12"
|
version = "0.13.2"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["rt_tokio_1"]
|
features = ["rt_tokio_1"]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.deadpool]
|
[dependencies.deadpool]
|
||||||
version = "0.10"
|
version = "0.12.1"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["rt_tokio_1", "managed"]
|
features = ["rt_tokio_1", "managed"]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.deadpool-redis]
|
[dependencies.deadpool-redis]
|
||||||
version = "0.14"
|
version = "0.15"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["rt_tokio_1"]
|
features = ["rt_tokio_1"]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
|
@ -103,12 +103,12 @@
|
||||||
//! Drivers have a varying degree of support for graceful shutdown, affected by
|
//! Drivers have a varying degree of support for graceful shutdown, affected by
|
||||||
//! the `Type::init()` fairing on Rocket shutdown.
|
//! the `Type::init()` fairing on Rocket shutdown.
|
||||||
//!
|
//!
|
||||||
//! ## `deadpool` (v0.9)
|
//! ## `deadpool` (v0.13)
|
||||||
//!
|
//!
|
||||||
//! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
|
//! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
|
||||||
//! |----------|-----------------------------|-----------------------------|--------------------------------------|
|
//! |----------|-----------------------------|-----------------------------|--------------------------------------|
|
||||||
//! | Postgres | `deadpool_postgres` (v0.12) | [`deadpool_postgres::Pool`] | [`deadpool_postgres::ClientWrapper`] |
|
//! | Postgres | `deadpool_postgres` (v0.13) | [`deadpool_postgres::Pool`] | [`deadpool_postgres::ClientWrapper`] |
|
||||||
//! | Redis | `deadpool_redis` (v0.14) | [`deadpool_redis::Pool`] | [`deadpool_redis::Connection`] |
|
//! | Redis | `deadpool_redis` (v0.15) | [`deadpool_redis::Pool`] | [`deadpool_redis::Connection`] |
|
||||||
//!
|
//!
|
||||||
//! On shutdown, new connections are denied. Shutdown _does not_ wait for
|
//! On shutdown, new connections are denied. Shutdown _does not_ wait for
|
||||||
//! connections to be returned.
|
//! connections to be returned.
|
||||||
|
|
|
@ -154,9 +154,8 @@ pub trait Pool: Sized + Send + Sync + 'static {
|
||||||
|
|
||||||
#[cfg(feature = "deadpool")]
|
#[cfg(feature = "deadpool")]
|
||||||
mod deadpool_postgres {
|
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 super::{Duration, Error, Config, Figment};
|
||||||
use rocket::Either;
|
|
||||||
|
|
||||||
pub trait DeadManager: Manager + Sized + Send + Sync + 'static {
|
pub trait DeadManager: Manager + Sized + Send + Sync + 'static {
|
||||||
fn new(config: &Config) -> Result<Self, Self::Error>;
|
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>
|
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
|
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;
|
type Connection = C;
|
||||||
|
|
||||||
async fn init(figment: &Figment) -> Result<Self, Self::Error> {
|
async fn init(figment: &Figment) -> Result<Self, Self::Error> {
|
||||||
let config: Config = figment.extract()?;
|
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)
|
Pool::builder(manager)
|
||||||
.max_size(config.max_connections)
|
.max_size(config.max_connections)
|
||||||
|
@ -195,7 +194,7 @@ mod deadpool_postgres {
|
||||||
.recycle_timeout(config.idle_timeout.map(Duration::from_secs))
|
.recycle_timeout(config.idle_timeout.map(Duration::from_secs))
|
||||||
.runtime(Runtime::Tokio1)
|
.runtime(Runtime::Tokio1)
|
||||||
.build()
|
.build()
|
||||||
.map_err(|e| Error::Init(Either::Right(e)))
|
.map_err(|_| Error::Init(PoolError::NoRuntimeSpecified))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get(&self) -> Result<Self::Connection, Self::Error> {
|
async fn get(&self) -> Result<Self::Connection, Self::Error> {
|
||||||
|
|
Loading…
Reference in New Issue