pub struct PoolSize {
pub max_open: u64,
pub max_idle: u64,
pub max_idle_lifetime: Option<Duration>,
pub get_timeout: Option<Duration>,
pub connect_timeout: Option<Duration>,
}Expand description
How a pool is sized and how long it waits.
The default suits a caller that runs a query at a time and has a person
watching. A caller that fans out sets these deliberately: max_open is a
budget against the server’s own connection limit rather than a slot per
concurrent caller, max_idle keeps the resting footprint proportional to
what the work actually leaves behind, and the two timeouts separate waiting
for a free connection from waiting for one to open — a busy server and an
unreachable one deserve very different patience.
Fields§
§max_open: u64§max_idle: u64§max_idle_lifetime: Option<Duration>How long an idle connection is kept before being closed. None keeps
idle connections until max_lifetime; a caller that works in bursts
sets this long enough to span the gap between them and no longer, so
connections survive burst to burst without being held indefinitely.
get_timeout: Option<Duration>How long to wait for a free connection before giving up. None waits as
long as it takes, so a caller with more work than slots queues rather
than being told the database is unavailable when it is merely busy.
This covers opening a connection as well as waiting for one, so a caller
that wants to distinguish the two sets connect_timeout too.
connect_timeout: Option<Duration>How long to wait for a connection to open. None leaves it to the
operating system, which can mean minutes of SYN retries when a host
drops packets rather than refusing.
A caller that is generous about queueing still wants this short: an unreachable database should be reported quickly, not waited out.