pub struct ConnectionPool { /* private fields */ }Expand description
Connection pool for a single backend address.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn new(
addr: SocketAddr,
max_idle: usize,
max_age_secs: u64,
fill_batch: usize,
fill_delay_ms: u64,
) -> Self
pub fn new( addr: SocketAddr, max_idle: usize, max_age_secs: u64, fill_batch: usize, fill_delay_ms: u64, ) -> Self
Create a new connection pool.
Sourcepub async fn get(&self) -> Result<TcpStream>
pub async fn get(&self) -> Result<TcpStream>
Get a fresh connection from the pool or create a new one.
Sourcepub fn cleanup(&self)
pub fn cleanup(&self)
Warm pool maintains fresh connections; used connections are not returned. Clean up expired connections.
Sourcepub fn start_cleanup_task(self: &Arc<Self>, interval: Duration)
pub fn start_cleanup_task(self: &Arc<Self>, interval: Duration)
Start a background warm-fill task.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConnectionPool
impl !RefUnwindSafe for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl UnsafeUnpin for ConnectionPool
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more