pub struct ConnectionPool { /* private fields */ }Expand description
Connection pool for coordinator client connections.
Manages a pool of connections with automatic reconnection, lifetime management, and configurable pool sizing.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn new(config: ConnectionPoolConfig) -> Self
pub fn new(config: ConnectionPoolConfig) -> Self
Create a new connection pool with the given configuration.
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Initialize the pool by creating min_idle connections.
Sourcepub async fn checkout(&self) -> Result<u64>
pub async fn checkout(&self) -> Result<u64>
Checkout a connection from the pool.
Returns a connection ID that should be returned via checkin after use.
If no idle connections are available and the pool is not at capacity, a
new connection is created. Retries with exponential backoff on failure.
Sourcepub async fn checkin(&self, conn_id: u64) -> Result<()>
pub async fn checkin(&self, conn_id: u64) -> Result<()>
Return a connection to the pool after use.
Sourcepub async fn mark_broken(&self, conn_id: u64) -> Result<()>
pub async fn mark_broken(&self, conn_id: u64) -> Result<()>
Mark a connection as broken (will be removed on next cleanup).
Sourcepub async fn execute_with_retry<F, T>(&self, operation: F) -> Result<T>
pub async fn execute_with_retry<F, T>(&self, operation: F) -> Result<T>
Execute an operation with automatic retry on failure.
operation is a closure that receives a connection ID and returns
Ok(T) on success or Err on failure. On failure, the connection
is marked broken and a new one is obtained for the next attempt.
Sourcepub fn advance_tick(&self, millis: u64)
pub fn advance_tick(&self, millis: u64)
Advance the internal tick (for testing and lifetime management).
Sourcepub async fn idle_count(&self) -> usize
pub async fn idle_count(&self) -> usize
Get the current number of idle connections.
Sourcepub fn retry_policy(&self) -> &RetryPolicy
pub fn retry_policy(&self) -> &RetryPolicy
Get the retry policy.
Sourcepub async fn health_check(&self) -> Result<usize>
pub async fn health_check(&self) -> Result<usize>
Perform health checks on idle connections, removing broken/expired ones.
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