PoolConfig

Struct PoolConfig 

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

Connection options.

§pool: PoolOptions

Pool options.

§retry_attempts: u32

Number of retry attempts for failed connections.

§retry_delay: Duration

Delay between retry attempts.

§health_check_interval: Option<Duration>

Health check interval.

Implementations§

Source§

impl PoolConfig

Source

pub fn new() -> Self

Create a new pool configuration.

Source

pub fn connection(self, options: ConnectionOptions) -> Self

Set connection options.

Source

pub fn pool(self, options: PoolOptions) -> Self

Set pool options.

Source

pub fn max_connections(self, n: u32) -> Self

Set max connections.

Source

pub fn min_connections(self, n: u32) -> Self

Set min connections.

Source

pub fn connect_timeout(self, timeout: Duration) -> Self

Set connection timeout.

Source

pub fn acquire_timeout(self, timeout: Duration) -> Self

Set acquire timeout.

Source

pub fn idle_timeout(self, timeout: Duration) -> Self

Set idle timeout.

Source

pub fn max_lifetime(self, lifetime: Duration) -> Self

Set max lifetime.

Source

pub fn retry_attempts(self, attempts: u32) -> Self

Set retry attempts.

Source

pub fn retry_delay(self, delay: Duration) -> Self

Set retry delay.

Source

pub fn health_check_interval(self, interval: Duration) -> Self

Set health check interval.

Source

pub fn no_health_check(self) -> Self

Disable health checks.

Source

pub fn low_latency() -> Self

Create a configuration optimized for low-latency.

Source

pub fn high_throughput() -> Self

Create a configuration optimized for high throughput.

Source

pub fn development() -> Self

Create a configuration for development/testing.

Source

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
Source

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
Source

pub fn mixed_workload() -> Self

Create a configuration optimized for mixed workloads.

Balanced settings for applications with both reads and writes.

Source

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
Source

pub fn serverless() -> Self

Create a configuration for serverless environments.

Features:

  • Quick connection acquisition
  • Aggressive connection recycling
  • No minimum connections (cold start friendly)
Source

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 second
  • avg_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

Source§

fn clone(&self) -> PoolConfig

Returns a duplicate of the value. Read more
1.0.0 · 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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