pub struct PoolBuilder { /* private fields */ }Expand description
Implementations§
Source§impl PoolBuilder
impl PoolBuilder
Sourcepub fn url(self, url: &str) -> Self
pub fn url(self, url: &str) -> Self
Configure the pool from a PostgreSQL connection URL.
Format: postgres://user:password@host:port/dbname
pub fn max_size(self, size: usize) -> Self
Sourcepub fn max_lifetime(self, d: Option<Duration>) -> Self
pub fn max_lifetime(self, d: Option<Duration>) -> Self
Set the maximum lifetime of a connection. Connections older than this are discarded when returned to the pool. Default: 30 minutes.
Pass None for unlimited lifetime.
Sourcepub fn max_lifetime_secs(self, secs: u64) -> Self
pub fn max_lifetime_secs(self, secs: u64) -> Self
Set the maximum lifetime in seconds. Convenience for
max_lifetime(Some(Duration::from_secs(secs))).
Sourcepub fn lifetime_secs(self, secs: u64) -> Self
pub fn lifetime_secs(self, secs: u64) -> Self
Shorthand for max_lifetime_secs.
Sourcepub fn acquire_timeout(self, d: Option<Duration>) -> Self
pub fn acquire_timeout(self, d: Option<Duration>) -> Self
Set the maximum time to wait for a connection when the pool is exhausted. Default: 5 seconds.
Pass None for fail-fast behavior (no waiting, immediate error).
Sourcepub fn acquire_timeout_secs(self, secs: u64) -> Self
pub fn acquire_timeout_secs(self, secs: u64) -> Self
Set the acquire timeout in seconds. Convenience for
acquire_timeout(Some(Duration::from_secs(secs))).
Sourcepub fn timeout_secs(self, secs: u64) -> Self
pub fn timeout_secs(self, secs: u64) -> Self
Shorthand for acquire_timeout_secs.
Sourcepub fn min_idle(self, n: usize) -> Self
pub fn min_idle(self, n: usize) -> Self
Set the minimum number of idle connections to maintain. Default: 0.
When greater than 0, a background task creates connections as needed to maintain this idle floor.
Sourcepub fn replica_url(self, url: &str) -> Self
pub fn replica_url(self, url: &str) -> Self
Set a read replica URL for read/write splitting.
When configured, query_raw_readonly (used by SELECT queries)
routes to the replica pool. All writes go to the primary.
When no replica is configured, all queries use the primary.
Sourcepub fn replica_max_size(self, size: usize) -> Self
pub fn replica_max_size(self, size: usize) -> Self
Set the max pool size for the replica pool.
Defaults to the same value as max_size.