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<PooledClient<'_>, HttpError>
pub async fn client(&mut self) -> Result<PooledClient<'_>, 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.
The returned PooledClient derefs to &mut HttpClient and, on
drop, recycles its slot if the peer signalled close
(HttpClient::peer_will_close). The next call to client()
will lazily reconnect that slot.
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 !RefUnwindSafe for Pool
impl !UnwindSafe for Pool
impl Freeze for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnsafeUnpin 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