pub struct Pool { /* private fields */ }Expand description
A fixed-size connection pool with round-robin dispatch.
All slots start disconnected. Call connect_all() for
eager startup, or let client() lazily reconnect on demand.
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new(config: PoolConfig) -> Self
pub fn new(config: PoolConfig) -> Self
Create a new pool. All slots start disconnected.
Sourcepub async fn connect_all(&mut self) -> Result<(), Error>
pub async fn connect_all(&mut self) -> Result<(), Error>
Eagerly connect all slots. Returns an error if any connection fails.
Sourcepub async fn client(&mut self) -> Result<Client, Error>
pub async fn client(&mut self) -> Result<Client, Error>
Get a Client bound to the next healthy connection.
Advances the round-robin cursor and returns a client for a connected
slot. Disconnected slots are lazily reconnected. If all slots fail,
returns Error::AllConnectionsFailed.
Sourcepub fn mark_disconnected(&mut self, conn: ConnCtx)
pub fn mark_disconnected(&mut self, conn: ConnCtx)
Mark a connection as dead after a ConnectionClosed error.
Matches by ConnCtx::token() and sets the slot to disconnected.
The next client() call will lazily reconnect.
Sourcepub fn connected_count(&self) -> usize
pub fn connected_count(&self) -> usize
Number of currently connected slots.
Auto Trait Implementations§
impl Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnsafeUnpin for Pool
impl UnwindSafe for Pool
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