pub struct Pool { /* private fields */ }Expand description
A fixed-size HTTP connection pool with round-robin dispatch.
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<(), HttpError>
pub async fn connect_all(&mut self) -> Result<(), HttpError>
Eagerly connect all slots.
Sourcepub async fn client(&mut self) -> Result<&mut HttpClient, HttpError>
pub async fn client(&mut self) -> Result<&mut HttpClient, HttpError>
Get a client bound to the next healthy connection.
Advances the round-robin cursor. Disconnected slots are lazily
reconnected. Returns HttpError::AllConnectionsFailed if all
slots fail.
Sourcepub fn mark_disconnected(&mut self, idx: usize)
pub fn mark_disconnected(&mut self, idx: usize)
Mark a slot as disconnected by index, closing the underlying connection.
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