pub struct ConnectionPool { /* private fields */ }Expand description
Connection pool for reusing HTTP/1.1, HTTP/2, and HTTP/3 connections
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn with_config(
max_idle: Duration,
max_per_host: usize,
max_streams: u32,
) -> Self
pub fn with_config( max_idle: Duration, max_per_host: usize, max_streams: u32, ) -> Self
Create a connection pool with custom configuration
Sourcepub async fn get_h1(&self, key: &PoolKey) -> Option<MaybeHttpsStream>
pub async fn get_h1(&self, key: &PoolKey) -> Option<MaybeHttpsStream>
Get an idle HTTP/1.1 connection from the pool
Sourcepub async fn put_h1(&self, key: PoolKey, stream: MaybeHttpsStream)
pub async fn put_h1(&self, key: PoolKey, stream: MaybeHttpsStream)
Return an HTTP/1.1 connection to the pool
Sourcepub async fn get_or_create(
&self,
key: &PoolKey,
version: HttpVersion,
) -> Result<Option<PoolEntry>>
pub async fn get_or_create( &self, key: &PoolKey, version: HttpVersion, ) -> Result<Option<PoolEntry>>
Get an existing connection or signal that a new one should be created
Returns:
Ok(Some(entry)): Reusable connection found (HTTP/2 or HTTP/3)Ok(None): No reusable connection, create new one
Sourcepub async fn invalidate(&self, key: &PoolKey)
pub async fn invalidate(&self, key: &PoolKey)
Invalidate a connection (due to error, GOAWAY, etc.)
Sourcepub fn spawn_cleanup_task(self: Arc<Self>, interval: Duration) -> JoinHandle<()>
pub fn spawn_cleanup_task(self: Arc<Self>, interval: Duration) -> JoinHandle<()>
Spawn a background cleanup task that runs periodically
Returns a handle to the spawned 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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more