Struct deadpool::managed::PoolBuilder
source · pub struct PoolBuilder<M, W = Object<M>>where
M: Manager,
W: From<Object<M>>,{ /* private fields */ }
Expand description
Builder for Pool
s.
Instances of this are created by calling the Pool::builder()
method.
Implementations§
source§impl<M, W> PoolBuilder<M, W>where
M: Manager,
W: From<Object<M>>,
impl<M, W> PoolBuilder<M, W>where M: Manager, W: From<Object<M>>,
sourcepub fn config(self, value: PoolConfig) -> Self
pub fn config(self, value: PoolConfig) -> Self
Sets a PoolConfig
to build the Pool
with.
sourcepub fn max_size(self, value: usize) -> Self
pub fn max_size(self, value: usize) -> Self
Sets the PoolConfig::max_size
.
sourcepub fn timeouts(self, value: Timeouts) -> Self
pub fn timeouts(self, value: Timeouts) -> Self
Sets the PoolConfig::timeouts
.
sourcepub fn wait_timeout(self, value: Option<Duration>) -> Self
pub fn wait_timeout(self, value: Option<Duration>) -> Self
Sets the Timeouts::wait
value of the PoolConfig::timeouts
.
sourcepub fn create_timeout(self, value: Option<Duration>) -> Self
pub fn create_timeout(self, value: Option<Duration>) -> Self
Sets the Timeouts::create
value of the PoolConfig::timeouts
.
sourcepub fn recycle_timeout(self, value: Option<Duration>) -> Self
pub fn recycle_timeout(self, value: Option<Duration>) -> Self
Sets the Timeouts::recycle
value of the PoolConfig::timeouts
.
sourcepub fn post_create(self, hook: impl Into<Hook<M>>) -> Self
pub fn post_create(self, hook: impl Into<Hook<M>>) -> Self
Attaches a post_create
hook.
The given hook
will be called each time right after a new Object
has been created.
sourcepub fn pre_recycle(self, hook: impl Into<Hook<M>>) -> Self
pub fn pre_recycle(self, hook: impl Into<Hook<M>>) -> Self
Attaches a pre_recycle
hook.
The given hook
will be called each time right before an Object
will
be recycled.
sourcepub fn post_recycle(self, hook: impl Into<Hook<M>>) -> Self
pub fn post_recycle(self, hook: impl Into<Hook<M>>) -> Self
Attaches a post_recycle
hook.
The given hook
will be called each time right after an Object
has
been recycled.
sourcepub fn runtime(self, value: Runtime) -> Self
pub fn runtime(self, value: Runtime) -> Self
Sets the Runtime
.
Important
The Runtime
is optional. Most Pool
s don’t need a
Runtime
. If want to utilize timeouts, however a Runtime
must be
specified as you will otherwise get a PoolError::NoRuntimeSpecified
when trying to use Pool::timeout_get()
.
PoolBuilder::build()
will fail with a
BuildError::NoRuntimeSpecified
if you try to build a
Pool
with timeouts and no Runtime
specified.