pub struct ConnectionPool { /* private fields */ }Expand description
Connection pool for managing QUIC connections
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn new(host: impl Into<String>, port: u16, max_size: usize) -> Self
pub fn new(host: impl Into<String>, port: u16, max_size: usize) -> Self
Create a new connection pool.
§Panics
Panics if max_size is 0. A connection pool must have at least one
connection slot to function properly. (Gap #18: CWE-400, CWE-835)
Sourcepub fn from_dsn(dsn: &str) -> Result<Self>
pub fn from_dsn(dsn: &str) -> Result<Self>
Build a pool from a DSN string using the default max size (16).
§Errors
Returns an error if the DSN is invalid.
Sourcepub fn from_dsn_with_size(dsn: &str, max_size: usize) -> Result<Self>
pub fn from_dsn_with_size(dsn: &str, max_size: usize) -> Result<Self>
Sourcepub fn from_client(client: Client, max_size: usize) -> Self
pub fn from_client(client: Client, max_size: usize) -> Self
Sourcepub fn skip_verify(self, skip: bool) -> Self
pub fn skip_verify(self, skip: bool) -> Self
Configure to skip TLS verification
Sourcepub fn username(self, username: impl Into<String>) -> Self
pub fn username(self, username: impl Into<String>) -> Self
Set the authentication username used for new pooled connections.
Sourcepub fn password(self, password: impl Into<String>) -> Self
pub fn password(self, password: impl Into<String>) -> Self
Set the authentication password used for new pooled connections.
Sourcepub async fn acquire(&self) -> Result<PooledConnection>
pub async fn acquire(&self) -> Result<PooledConnection>
Acquire a connection from the pool
Returns a healthy connection from the pool, or creates a new one if needed. Stale connections (those where the underlying QUIC connection has been closed) are automatically discarded during acquisition.
Sourcepub async fn batch_exec(&self, stmts: &[Statement]) -> Result<()>
pub async fn batch_exec(&self, stmts: &[Statement]) -> Result<()>
Execute statements as a single batch in one transaction, with the default retry policy. Acquires one connection from the pool.
§Errors
Returns the first failing statement’s error (the transaction is rolled back). An empty slice is a no-op.
Sourcepub async fn pipeline_exec(
self: &Arc<Self>,
stmts: &[Statement],
chunk_size: usize,
max_workers: usize,
) -> Result<()>
pub async fn pipeline_exec( self: &Arc<Self>, stmts: &[Statement], chunk_size: usize, max_workers: usize, ) -> Result<()>
Execute statements concurrently in chunks, each chunk a single
transaction (via batch_exec with retry). At most
max_workers chunks run at once. The first error stops dispatching new
chunks; in-flight chunks complete. chunk_size/max_workers of 0 use
the defaults (100 / 8).
§Errors
Returns the first error recorded across all chunks.
Auto Trait Implementations§
impl !RefUnwindSafe for ConnectionPool
impl !UnwindSafe for ConnectionPool
impl Freeze for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl UnsafeUnpin for ConnectionPool
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> 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