deadpool diesel -> error Timeouts require a runtime
Closed this issue · 2 comments
Cloud33 commented
toml:
diesel = { version = "1.4.8", features = ["postgres","chrono","uuid"] }
deadpool-diesel = { version = "0.3.1", features=["postgres","serde","rt_tokio_1"]}
code
let manager = Manager::new(&database_url, Runtime::Tokio1);
let pool = Pool::builder(manager)
.max_size(max_connections)
.wait_timeout(Some(Duration::from_millis(5000)))
.create_timeout(Some(Duration::from_millis(5000)))
.recycle_timeout(Some(Duration::from_millis(5000)))
.build()?;
error:
Error occurred while building the pool: NoRuntimeSpecified: Timeouts require a runtime'
Why, I have a specified runtime
bikeshedder commented
That's quite unfortunate. The Manager
and the Pool
are separate structures.
For the PoolBuilder
to know the Runtime
you need to call .runtime(Runtime::Tokio)
on it as well.
This might indeed be a convenience feature if the PoolBuilder
could read the runtime from the Manager
object. Right now the Pool
has no way of knowing which Runtime
was passed to the Manager
and therefore you need to call that method on the PoolBuilder
as well.
The way managers and pools are constructed have always bugged me. I just created issue #197 to track the progress of this.
Cloud33 commented
Thank you for your efforts