Struct mobc::Builder

source ·
pub struct Builder<M> { /* private fields */ }
Expand description

A builder for a connection pool.

Implementations§

Constructs a new Builder.

Parameters are initialized with their default values.

Sets the maximum number of connections managed by the pool.

  • 0 means unlimited.
  • Defaults to 10.

Sets the maximum idle connection count maintained by the pool.

The pool will maintain at most this many idle connections at all times, while respecting the value of max_open.

  • Defaults to 2.

If true, the health of a connection will be verified via a call to Manager::check before it is checked out of the pool.

  • Defaults to true.

Sets the maximum lifetime of connections in the pool.

Expired connections may be closed lazily before reuse.

  • None means reuse forever.
  • Defaults to None.
Panics

Panics if max_lifetime is the zero Duration.

Sets the maximum lifetime of connection to be idle in the pool, resetting the timer when connection is used.

Expired connections may be closed lazily before reuse.

  • None means reuse forever.
  • Defaults to None.
Panics

Panics if max_idle_lifetime is the zero Duration.

Sets the get timeout used by the pool.

Calls to Pool::get will wait this long for a connection to become available before returning an error.

  • None means never timeout.
  • Defaults to 30 seconds.
Panics

Panics if connection_timeout is the zero duration

Sets the interval how often a connection will be checked when returning an existing connection from the pool. If set to None, a connection is checked every time when returning from the pool. Must be used together with test_on_check_out set to true, otherwise does nothing.

  • None means a connection is checked every time when returning from the pool.
  • Defaults to None.
Panics

Panics if connection_timeout is the zero duration

Consumes the builder, returning a new, initialized pool.

Panics

Panics if max_idle is greater than max_size.

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more