pub struct PoolOptions {
pub max_connections: Option<u32>,
pub min_connections: Option<u32>,
pub acquire_timeout: Option<Duration>,
pub idle_timeout: Option<Duration>,
pub max_lifetime: Option<Duration>,
pub statement_timeout: Option<Duration>,
pub idle_in_transaction_session_timeout: Option<Duration>,
}Expand description
Connection-pool configuration for the Postgres backend.
All fields are optional; unset fields fall back to sqlx defaults
(e.g. max_connections = 10, no idle/lifetime caps, no session-level
timeouts).
statement_timeout and idle_in_transaction_session_timeout are applied
at the session level via SET on every newly-acquired connection, so
they affect every query the pool serves without requiring a server-side
configuration change.
Construct via PoolOptions::default() and field-assign, or pass directly
to PostgresBackend::connect_with_options.
Fields§
§max_connections: Option<u32>Maximum number of connections held by the pool. sqlx default: 10.
min_connections: Option<u32>Minimum number of connections kept warm. sqlx default: 0.
acquire_timeout: Option<Duration>Time to wait for a connection from the pool before erroring out.
idle_timeout: Option<Duration>Drop connections idle for longer than this.
max_lifetime: Option<Duration>Recycle connections older than this regardless of idle state.
statement_timeout: Option<Duration>statement_timeout value applied to every connection. Aborts queries
that run longer than this duration.
Note: sub-millisecond and zero durations are floored at 1 ms, because
PG interprets a 0 value as “timeout disabled” — the opposite of
what such a tight bound would suggest. Pass None to leave the
server default in place (typically no timeout).
idle_in_transaction_session_timeout: Option<Duration>idle_in_transaction_session_timeout value applied to every
connection. Aborts transactions that sit idle for longer than this
duration, releasing the connection and unblocking VACUUM.
Subject to the same sub-millisecond floor as statement_timeout.
Trait Implementations§
Source§impl Clone for PoolOptions
impl Clone for PoolOptions
Source§fn clone(&self) -> PoolOptions
fn clone(&self) -> PoolOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PoolOptions
impl Debug for PoolOptions
Source§impl Default for PoolOptions
impl Default for PoolOptions
Source§fn default() -> PoolOptions
fn default() -> PoolOptions
Auto Trait Implementations§
impl Freeze for PoolOptions
impl RefUnwindSafe for PoolOptions
impl Send for PoolOptions
impl Sync for PoolOptions
impl Unpin for PoolOptions
impl UnsafeUnpin for PoolOptions
impl UnwindSafe for PoolOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more