pub struct SyncPoolConfig {
pub endpoint: String,
pub database: String,
pub create_mode: CreateMode,
pub user: Option<String>,
pub password: Option<String>,
pub max_size: usize,
pub recycle: SyncRecycleStrategy,
pub wait_timeout: Option<Duration>,
pub max_lifetime: Option<Duration>,
pub idle_timeout: Option<Duration>,
pub min_idle: Option<u32>,
}Expand description
Configuration and builder for the synchronous ConnectionPool.
Mirrors the async PoolConfig surface. All optional knobs default to
None/disabled and recycle defaults to
SyncRecycleStrategy::SelectOne, so a config that sets only
endpoint/database/max_size opens connections lazily and probes them with
SELECT 1 on checkout — the natural baseline.
§Timeout support
The sync pool enforces wait_timeout natively (it
bounds how long ConnectionPool::get blocks waiting for a slot).
create_timeout and recycle_timeout require an async runtime to interrupt
a blocking syscall and are therefore async-only (PoolConfig); they
are intentionally absent here to avoid pulling Tokio into the sync path.
Fields§
§endpoint: StringServer endpoint (e.g., “localhost:7483”).
database: StringDatabase path.
create_mode: CreateModeDatabase creation mode (only used for the first connection).
user: Option<String>Optional username for authentication.
password: Option<String>Optional password for authentication.
max_size: usizeMaximum number of connections in the pool.
recycle: SyncRecycleStrategyPer-checkout recycle strategy. Defaults to SyncRecycleStrategy::SelectOne.
wait_timeout: Option<Duration>Maximum time ConnectionPool::get blocks waiting for a slot. None
waits indefinitely (the default).
max_lifetime: Option<Duration>Maximum lifetime of a physical connection before it is retired at checkout.
idle_timeout: Option<Duration>Maximum idle time before a connection is retired at checkout (down to
min_idle, which is kept warm).
min_idle: Option<u32>Minimum number of idle connections to keep warm (biases idle eviction).
Implementations§
Source§impl SyncPoolConfig
impl SyncPoolConfig
Sourcepub fn new(endpoint: impl Into<String>, database: impl Into<String>) -> Self
pub fn new(endpoint: impl Into<String>, database: impl Into<String>) -> Self
Creates a new synchronous pool configuration.
Sourcepub fn create_mode(self, mode: CreateMode) -> Self
pub fn create_mode(self, mode: CreateMode) -> Self
Sets the database creation mode.
Sourcepub fn auth(self, user: impl Into<String>, password: impl Into<String>) -> Self
pub fn auth(self, user: impl Into<String>, password: impl Into<String>) -> Self
Sets authentication credentials.
Sourcepub fn recycle(self, strategy: SyncRecycleStrategy) -> Self
pub fn recycle(self, strategy: SyncRecycleStrategy) -> Self
Sets the per-checkout recycle strategy.
Sourcepub fn wait_timeout(self, timeout: Option<Duration>) -> Self
pub fn wait_timeout(self, timeout: Option<Duration>) -> Self
Sets the maximum time get blocks waiting for a slot.
Sourcepub fn max_lifetime(self, lifetime: Option<Duration>) -> Self
pub fn max_lifetime(self, lifetime: Option<Duration>) -> Self
Sets the maximum lifetime of a physical connection.
Sourcepub fn idle_timeout(self, timeout: Option<Duration>) -> Self
pub fn idle_timeout(self, timeout: Option<Duration>) -> Self
Sets the maximum idle time before a connection is retired at checkout.
Sourcepub fn min_idle(self, min_idle: Option<u32>) -> Self
pub fn min_idle(self, min_idle: Option<u32>) -> Self
Sets the minimum number of idle connections to keep warm.
Sourcepub fn build(self) -> ConnectionPool
pub fn build(self) -> ConnectionPool
Builds the synchronous connection pool. Connections are opened lazily on
first ConnectionPool::get.
Trait Implementations§
Source§impl Clone for SyncPoolConfig
impl Clone for SyncPoolConfig
Source§fn clone(&self) -> SyncPoolConfig
fn clone(&self) -> SyncPoolConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SyncPoolConfig
impl !UnwindSafe for SyncPoolConfig
impl Freeze for SyncPoolConfig
impl Send for SyncPoolConfig
impl Sync for SyncPoolConfig
impl Unpin for SyncPoolConfig
impl UnsafeUnpin for SyncPoolConfig
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request