pub struct PoolConfig {
pub connection: ConnectionOptions,
pub pool: PoolOptions,
pub retry_attempts: u32,
pub retry_delay: Duration,
pub health_check_interval: Option<Duration>,
}Expand description
Complete pool configuration combining connection and pool options.
Fields§
§connection: ConnectionOptionsConnection options.
pool: PoolOptionsPool options.
retry_attempts: u32Number of retry attempts for failed connections.
retry_delay: DurationDelay between retry attempts.
health_check_interval: Option<Duration>Health check interval.
Implementations§
Source§impl PoolConfig
impl PoolConfig
Sourcepub fn connection(self, options: ConnectionOptions) -> Self
pub fn connection(self, options: ConnectionOptions) -> Self
Set connection options.
Sourcepub fn pool(self, options: PoolOptions) -> Self
pub fn pool(self, options: PoolOptions) -> Self
Set pool options.
Sourcepub fn max_connections(self, n: u32) -> Self
pub fn max_connections(self, n: u32) -> Self
Set max connections.
Sourcepub fn min_connections(self, n: u32) -> Self
pub fn min_connections(self, n: u32) -> Self
Set min connections.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set connection timeout.
Sourcepub fn acquire_timeout(self, timeout: Duration) -> Self
pub fn acquire_timeout(self, timeout: Duration) -> Self
Set acquire timeout.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
pub fn idle_timeout(self, timeout: Duration) -> Self
Set idle timeout.
Sourcepub fn max_lifetime(self, lifetime: Duration) -> Self
pub fn max_lifetime(self, lifetime: Duration) -> Self
Set max lifetime.
Sourcepub fn retry_attempts(self, attempts: u32) -> Self
pub fn retry_attempts(self, attempts: u32) -> Self
Set retry attempts.
Sourcepub fn retry_delay(self, delay: Duration) -> Self
pub fn retry_delay(self, delay: Duration) -> Self
Set retry delay.
Sourcepub fn health_check_interval(self, interval: Duration) -> Self
pub fn health_check_interval(self, interval: Duration) -> Self
Set health check interval.
Sourcepub fn no_health_check(self) -> Self
pub fn no_health_check(self) -> Self
Disable health checks.
Sourcepub fn low_latency() -> Self
pub fn low_latency() -> Self
Create a configuration optimized for low-latency.
Sourcepub fn high_throughput() -> Self
pub fn high_throughput() -> Self
Create a configuration optimized for high throughput.
Sourcepub fn development() -> Self
pub fn development() -> Self
Create a configuration for development/testing.
Sourcepub fn read_heavy() -> Self
pub fn read_heavy() -> Self
Create a configuration optimized for read-heavy workloads.
Features:
- More connections (reads can parallelize)
- Longer connection lifetime (cached statement benefits)
- Moderate health check interval
Sourcepub fn write_heavy() -> Self
pub fn write_heavy() -> Self
Create a configuration optimized for write-heavy workloads.
Features:
- Fewer connections (writes are serialized)
- Shorter lifetime (avoid long-running transactions)
- Frequent health checks
Sourcepub fn mixed_workload() -> Self
pub fn mixed_workload() -> Self
Create a configuration optimized for mixed workloads.
Balanced settings for applications with both reads and writes.
Sourcepub fn batch_processing() -> Self
pub fn batch_processing() -> Self
Create a configuration optimized for batch processing.
Features:
- Longer timeouts for batch operations
- More connections for parallel batch processing
- Infrequent health checks
Sourcepub fn serverless() -> Self
pub fn serverless() -> Self
Create a configuration for serverless environments.
Features:
- Quick connection acquisition
- Aggressive connection recycling
- No minimum connections (cold start friendly)
Sourcepub fn for_workload(qps: u32, avg_query_ms: u32) -> Self
pub fn for_workload(qps: u32, avg_query_ms: u32) -> Self
Recommend a configuration based on expected queries per second.
§Arguments
qps- Expected queries per secondavg_query_ms- Average query duration in milliseconds
§Example
use prax_query::connection::PoolConfig;
// 100 queries/sec with 10ms average latency
let config = PoolConfig::for_workload(100, 10);
assert!(config.pool.max_connections >= 5);Trait Implementations§
Source§impl Clone for PoolConfig
impl Clone for PoolConfig
Source§fn clone(&self) -> PoolConfig
fn clone(&self) -> PoolConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more