pub struct PgPoolConfig {
pub max_size: usize,
pub min_size: usize,
pub max_lifetime: Option<Duration>,
pub idle_timeout: Option<Duration>,
pub checkout_timeout: Option<Duration>,
pub connection_timeout: Option<Duration>,
pub test_on_checkout: bool,
pub validation_query: String,
pub auto_reconnect: bool,
}Expand description
Pool configuration options.
Fields§
§max_size: usizeMaximum number of connections in this pool.
min_size: usizeMinimum number of connections to maintain (eagerly created).
max_lifetime: Option<Duration>Maximum lifetime of a connection before it is closed and recreated.
idle_timeout: Option<Duration>Close connections that have been idle for longer than this.
checkout_timeout: Option<Duration>Maximum time to wait when all connections are busy (get()).
connection_timeout: Option<Duration>Maximum time to wait when creating a new connection.
test_on_checkout: boolIf true, run a validation query before returning a connection from the pool.
validation_query: StringThe query to use for validation (default: "SELECT 1").
auto_reconnect: boolIf true, automatically reconnect when a connection is found to be dead.
Implementations§
Source§impl PgPoolConfig
impl PgPoolConfig
Sourcepub fn max_lifetime(self, duration: Duration) -> Self
pub fn max_lifetime(self, duration: Duration) -> Self
Set the maximum connection lifetime.
Sourcepub fn idle_timeout(self, duration: Duration) -> Self
pub fn idle_timeout(self, duration: Duration) -> Self
Set the idle timeout.
Sourcepub fn checkout_timeout(self, duration: Duration) -> Self
pub fn checkout_timeout(self, duration: Duration) -> Self
Set the checkout timeout (how long get() waits for a free connection).
Sourcepub fn connection_timeout(self, duration: Duration) -> Self
pub fn connection_timeout(self, duration: Duration) -> Self
Set the connection timeout.
Sourcepub fn test_on_checkout(self, enable: bool) -> Self
pub fn test_on_checkout(self, enable: bool) -> Self
Enable or disable test-on-checkout.
Sourcepub fn no_max_lifetime(self) -> Self
pub fn no_max_lifetime(self) -> Self
Disable max lifetime.
Sourcepub fn no_idle_timeout(self) -> Self
pub fn no_idle_timeout(self) -> Self
Disable idle timeout.
Trait Implementations§
Source§impl Clone for PgPoolConfig
impl Clone for PgPoolConfig
Source§fn clone(&self) -> PgPoolConfig
fn clone(&self) -> PgPoolConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more