pub struct PoolPrewarmConfig {
pub min_size: usize,
pub max_size: usize,
pub timeout_secs: Option<u64>,
pub search_path: Option<SearchPath>,
pub tls: PostgresTlsConfig,
pub max_streaming_reads: Option<usize>,
pub vector_scan: VectorScanConfig,
pub read_replicas: Option<ReadReplicaConfig>,
}Expand description
Configuration for connection pool construction and pre-warming.
Controls the minimum guaranteed connections (pre-warmed at startup), the maximum pool ceiling, and the wait/create timeout for connection acquisition.
§Example
use fraiseql_db::postgres::{PoolPrewarmConfig, PostgresTlsConfig, VectorScanConfig};
let cfg = PoolPrewarmConfig {
min_size: 5,
max_size: 20,
timeout_secs: Some(30),
search_path: None,
// Mandatory: every pool site must state its transport security (#801/#824).
tls: PostgresTlsConfig::default(),
// Mandatory: every pool site must state its replica topology (#407).
read_replicas: None,
// `None` derives a quarter of `max_size` (#958).
max_streaming_reads: None,
// Continue a filtered ANN scan until `k` rows survive (#1116).
vector_scan: VectorScanConfig::default(),
};Fields§
§min_size: usizeNumber of connections to establish at pool creation time.
After the pool is created, min_size connections are opened eagerly
so they are ready when the first request arrives. Set to 0 to disable
pre-warming (lazy init — one connection from the startup health check).
max_size: usizeMaximum number of connections the pool may hold.
timeout_secs: Option<u64>Optional timeout (in seconds) for connection acquisition and creation.
Applied to both the wait (blocked waiting for an idle connection) and
create (time to open a new TCP connection to PostgreSQL) deadpool slots.
When None, acquisition can block indefinitely on pool exhaustion.
search_path: Option<SearchPath>Schema search path every connection in this pool must resolve unqualified
relations against. None leaves the server default in force.
This is a pool property, not a session one: it is lowered into the
PostgreSQL startup options parameter, so the server applies it while
establishing each connection — including connections deadpool opens later
to grow the pool, and replacements it creates after a backend dies. See
SearchPath for why the session-SET alternative is unsound.
tls: PostgresTlsConfigTransport security for every connection this pool opens.
Mandatory, and deliberately not Option: the pool used to be built with
NoTls unconditionally while three separate configuration surfaces claimed
to control database TLS, so each caller must now state what it wants and a
new pool site cannot compile without deciding (#801, #824). Callers with no
opinion pass PostgresTlsConfig::default (libpq’s prefer).
max_streaming_reads: Option<usize>How many of this pool’s connections may be held by streaming reads at once
(#958). None derives a quarter of max_size, at least 1.
A streamed read holds its connection for the whole life of the stream — for
an export, that is however long the client takes to consume a table, not
however long a query takes to run. Without a bound below max_size,
concurrent exports can occupy every connection in the pool and ordinary
requests then fail on the acquisition timeout: a feature for large reads
would take the server down by being used.
The bound is not a queue-length limit. A streaming read past the bound waits for a slot, exactly as any read waits for a connection.
vector_scan: VectorScanConfigpgvector scan behaviour for every connection this pool opens (#1116).
Defaults, via VectorScanConfig, to continuing an index scan until k
rows survive a filter. pgvector’s own default stops at one bounded
candidate list, which makes a filtered similarity search return fewer
rows than asked for and report success — the reason this is not left
to the server’s setting.
Like search_path it is lowered into the startup
packet, so it reaches every connection the pool opens later, and it is
inert on a database without pgvector.
read_replicas: Option<ReadReplicaConfig>Read replicas for this pool set, or None for a single-primary adapter.
Like tls, this is a mandatory decision at every pool site:
replica pools are built from this same config — the same
search_path, the same tls, the same
sizing — so tenant isolation and transport security cannot silently differ
between the primary and a replica (#809 generalised: isolation is a
property of how every pool’s connections are made). See
ReadReplicaConfig for the routing and consistency rules (#407).
Trait Implementations§
Source§impl Clone for PoolPrewarmConfig
impl Clone for PoolPrewarmConfig
Source§fn clone(&self) -> PoolPrewarmConfig
fn clone(&self) -> PoolPrewarmConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more