deadpool
deadpool copied to clipboard
Expose API for providing a custom Connect impl and pass through the `runtime` feature
Currently, deadpool-postgres
only offers APIs for creating pools that instantiate their underlying connections based on a tokio_postgres::Config
. In some situations (mocking, custom networking), it is useful to provide an alternate connection mechanism. Thankfully, deadpool-postgres
already has the Client
trait for this so we just need to expose it publicly. As part of this, we also expose the existing ConnectImpl
as a public ConfigConnectImpl
for code that needs to abstract over a selection of connection strategy.
Our main use case for this is to enable use on WASM, where tokio_postgres
is already supported but does not have the tokio-postgres/runtime
feature enabled (which enables the APIs for creation based on a database URL). So this PR also adds a runtime
feature that maps to the underlying tokio-postgres
one for now (defaulting to true to preserve compatibility). It also includes a minor patch to disable the keepalives_idle
config on WASM where it is not supported.
For tests, let me look into adding CI logic to test at least compilation on WASM.
In theory, the new CI config should test compilation on WASM!
I just removed the runtime
feature replacing it by conditional dependencies instead:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio-postgres = "0.7.9"
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio-postgres = { version = "0.7.9", default-features = false }
Could you please check if that works for you?
This should be a non breaking release for non-WASM targets now.
@bikeshedder oh actually I think this doesn't work, due to https://github.com/rust-lang/cargo/issues/1197
In our downstream crates we are seeing the default features pulled in when compiling on WASM.