#[non_exhaustive]pub struct DatabaseConfig {
pub url: String,
pub pool_size: u32,
pub pool_timeout: DurationStr,
pub statement_timeout: DurationStr,
pub replica_urls: Vec<String>,
pub read_from_replica: bool,
pub replica_pool_size: Option<u32>,
pub min_pool_size: u32,
pub test_before_acquire: bool,
}Expand description
Database configuration. One pool, no per-workload isolation: workload
separation belongs at the worker level, not the connection level. The
single-pool contention model and sizing formula are documented at the
runtime side in forge_runtime::pg::pool module docs.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.url: StringPostgreSQL connection URL.
pool_size: u32Connection pool size. Should be sized as `worker.max_concurrent + reactor cap + expected gateway concurrency
- ~6 for persistent listeners, leader holds, and headroom
. Seeforge_runtime::pg::pool` module docs.
pool_timeout: DurationStrPool checkout timeout duration (e.g. “30s”, “1m”).
statement_timeout: DurationStrStatement timeout duration (e.g. “30s”, “5m”).
replica_urls: Vec<String>Read replica URLs for scaling reads.
read_from_replica: boolWhether to route read queries to replicas.
replica_pool_size: Option<u32>Replica pool size. When unset, defaults to pool_size / 2.
min_pool_size: u32Minimum connections to keep alive in the pool (pre-warming).
test_before_acquire: boolRun a health check query before handing out connections. Disabling this halves round-trips for read queries.
Implementations§
Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§fn clone(&self) -> DatabaseConfig
fn clone(&self) -> DatabaseConfig
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 DatabaseConfig
impl Debug for DatabaseConfig
Source§impl Default for DatabaseConfig
impl Default for DatabaseConfig
Source§impl<'de> Deserialize<'de> for DatabaseConfig
impl<'de> Deserialize<'de> for DatabaseConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnsafeUnpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
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
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