Skip to main content

PoolBuilder

Struct PoolBuilder 

Source
pub struct PoolBuilder { /* private fields */ }
Expand description

Builder for configuring a connection pool.

Implementations§

Source§

impl PoolBuilder

Source

pub fn url(self, url: &str) -> Self

Set the connection URL.

Source

pub fn max_size(self, size: usize) -> Self

Set the maximum pool size. Default: 10.

A max_size of 0 means the pool will reject all acquire() calls immediately.

Source

pub fn max_lifetime(self, lifetime: Option<Duration>) -> Self

Set the maximum lifetime of a connection. Default: 30 minutes. Set to None for unlimited lifetime.

Source

pub fn acquire_timeout(self, timeout: Option<Duration>) -> Self

Set the acquire timeout. Default: 5 seconds. Set to None for fail-fast behavior when the pool is exhausted.

Source

pub fn min_idle(self, count: usize) -> Self

Set the minimum number of idle connections. Default: 0. When > 0, a background thread maintains this many idle connections.

Source

pub fn max_stmt_cache_size(self, size: usize) -> Self

Set the maximum number of cached prepared statements per connection. Default: 256. When the cache exceeds this size, the least recently used statement is evicted (Close sent to PG to free server memory).

Source

pub fn stale_timeout(self, timeout: Duration) -> Self

Set the maximum idle duration before a connection is considered stale. Default: 30 seconds. Connections idle longer than this are dropped on acquire instead of being reused.

Source

pub fn build(self) -> Result<Pool, DriverError>

Build the pool. Validates the URL but does not open connections.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.