Skip to main content

PoolConfig

Struct PoolConfig 

Source
pub struct PoolConfig {
    pub path: Option<PathBuf>,
    pub max_readers: usize,
    pub wal_mode: bool,
    pub busy_timeout: Duration,
    pub checkout_timeout: Duration,
    pub journal_size_limit_bytes: i64,
    pub read_only: bool,
    pub write_queue_enabled: Option<bool>,
    pub write_queue_capacity: usize,
    pub write_routing_strict: bool,
    pub write_admission_deadline_ms: u64,
    pub read_tx_max_age: Duration,
}
Expand description

Configuration for the connection pool.

Fields§

§path: Option<PathBuf>

Database path. None = in-memory (pool degrades to single connection).

§max_readers: usize

Number of reader connections (default: min(num_cpus, 8)).

§wal_mode: bool

WAL mode (must be true for pooling to work; default: true).

§busy_timeout: Duration

Busy timeout per connection (default: 30s).

Overridable via KHIVE_BUSY_TIMEOUT_SECS.

§checkout_timeout: Duration

Time to wait for a reader connection before returning an error (default: 5s).

Overridable via KHIVE_CHECKOUT_TIMEOUT_SECS.

§journal_size_limit_bytes: i64

Maximum WAL journal size in bytes before SQLite resets the WAL.

Maps to PRAGMA journal_size_limit. Default: 64 MiB.

Overridable via KHIVE_JOURNAL_SIZE_LIMIT_BYTES.

§read_only: bool

Open the database read-only (default: false).

When true, the pool’s writer connection is opened with SQLITE_OPEN_READ_ONLY (no SQLITE_OPEN_CREATE, so a missing path is rejected instead of created) and PRAGMA query_only = ON is set on every connection that can execute SQL. Reader connections are already opened read-only regardless of this flag.

§write_queue_enabled: Option<bool>

Route migrated store write paths through the single-writer WriterTask channel (ADR-067 Component A) instead of the legacy per-call pool-mutex/standalone-connection path. Enabled by default for file-backed pools when unset; explicit override always wins. That default is a compatibility-routing posture subordinate to ADR-135 Amendment 1 and ADR-136 D1/D2 — the strict-routing default flip has NOT happened.

The store layer resolves all of its routed write paths at write time; the classification table in writer_task.rs remains the authoritative inventory. This tranche does not claim the repository-wide single-writer guarantee, and the strict default is still evidence-gated.

None means the caller expressed no preference: ConnectionPool::new resolves it once path is known, defaulting to true for file-backed pools and false for in-memory ones. Some(_) is an explicit preference and always wins, in both directions, over that default. An explicit Some(true) on an in-memory pool is accepted DELIBERATELY and emits a warning before degrading to the legacy path — an in-memory pool cannot host a writer task (writer_task::spawn’s standalone-connection open fails); see ConnectionPool::writer_task_handle and the explicit_true_stays_on_for_memory_backed_pool test.

Overridable via KHIVE_WRITE_QUEUE ("1" or "true", case-insensitive, sets Some(true); any other value sets Some(false); unset leaves it None).

§write_queue_capacity: usize

Bounded channel capacity for the WriterTask write queue.

Overridable via KHIVE_WRITE_QUEUE_CAPACITY. Default: 256 pending operations (ADR-067 Component A recommended default).

§write_routing_strict: bool

ADR-136 D1: when true, every covered store write path that would otherwise silently degrade to the legacy pool-mutex/standalone- connection path on a missing or failed WriterTask handle instead returns an error. Exercises the store-layer routing tranche toward ADR-135 F2’s strict-routing precondition without changing behavior for callers that never set the env var.

Overridable via KHIVE_WRITE_ROUTING (value "strict", case-insensitive; anything else, or unset, leaves this false).

§write_admission_deadline_ms: u64

Dedicated admission deadline (ADR-131 Decision 2) bounding ONLY the wait for capacity on the WriterTask write queue — WriterTaskHandle::send_bounded/send_top_level_bounded’s default timeout. Distinct from checkout_timeout, which bounds reader/pool checkout instead; the two authorities used to be conflated (#1382, #1643) before this field existed.

Default: 2000 ms. Validated at ConnectionPool::new to fall in [100, 10000] ms; a value outside that range is a configuration error (SqliteError::InvalidConfig), never silently clamped into range.

Overridable via KHIVE_WRITE_ADMISSION_DEADLINE_MS.

§read_tx_max_age: Duration

Maximum age an explicit cached-reader read transaction (sql_bridge’s BEGIN-then-reuse path) may reach before its next use is refused and it is rolled back instead of extending its WAL snapshot further (#1846). Shares KHIVE_TX_MAX_AGE_SECS with the ADR-091 Plank 1 visibility sweep in checkpoint.rs so one knob governs both when an operator is warned about a stale reader and when that reader’s snapshot is actually released.

Overridable via KHIVE_TX_MAX_AGE_SECS. Default: 120 seconds.

Trait Implementations§

Source§

impl Clone for PoolConfig

Source§

fn clone(&self) -> Self

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 PoolConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PoolConfig

Source§

fn default() -> Self

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
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<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