Replies: 1 comment
-
|
You'd probably actually just need to implement Pulling the deadpool_postgress impl from the rocket_db_pools code, it would look something like this: pub struct CustomPool(deadpool::managed::Pool<M>);
#[rocket::async_trait]
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<PoolError<M::Error>>;
type Connection = C;
async fn init(figment: &Figment) -> Result<Self, Self::Error> {
let config: Config = figment.extract()?;
let manager = Self::new(
config.url.parse().map_err(|e| Error::Init(e.into()))?,
// Provide actual deadpool_postgres tls implementation
deadpool_postgres::tokio_postgres::NoTls
);
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(PoolError::NoRuntimeSpecified))
}
async fn get(&self) -> Result<Self::Connection, Self::Error> {
self.0.get().await.map_err(Error::Get)
}
async fn close(&self) {
// Pre-close logic goes here
<Pool<M, C>>::close(self.0)
}
}If you're interested in sharing your deadpool/postgres/rustls implementation, we might be able to include it Rocket out of the box. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Just trying to use Postgres with rocket_db_pools and switching to TLS.
I am using manually constructed pools usually (deadpool + rustls), but with rocket_db_pools I currently relied on normal connection strings. That does not allow me to set certain options like specific root certificates to be accepted etc.
In general it seems that SSL / TLS is a bit hard to configure.
Is there any decent workaround? Would implementing the 'Database' trait manually help? Does that allow me to construct the
poolmyself?Beta Was this translation helpful? Give feedback.
All reactions