Skip to main content

PoolPrewarmConfig

Struct PoolPrewarmConfig 

Source
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: usize

Number 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: usize

Maximum 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: PostgresTlsConfig

Transport 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: VectorScanConfig

pgvector 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

Source§

fn clone(&self) -> PoolPrewarmConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PoolPrewarmConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more