pub struct ConnPool<T> {
pub http: Arc<ConnPoolTable<T>>,
pub https: Arc<ConnPoolTable<T>>,
pub tasks: Arc<Mutex<JoinSet<()>>>,
}Expand description
Manages separate pools for HTTP and HTTPS connections, allowing for efficient connection reuse based on the target authority.
The connection pool maintains separate tables for HTTP and HTTPS connections, indexed by authority (host:port). Each entry contains a queue of pooled connections that can be reused for subsequent requests to the same authority.
Fields§
§http: Arc<ConnPoolTable<T>>Pool of HTTP connections indexed by authority
https: Arc<ConnPoolTable<T>>Pool of HTTPS connections indexed by authority
tasks: Arc<Mutex<JoinSet<()>>>Background tasks for connection management
Implementations§
Source§impl<T> ConnPool<T>
impl<T> ConnPool<T>
Sourcepub async fn evict(&self, timeout: Duration)
pub async fn evict(&self, timeout: Duration)
Evicts connections from both HTTP and HTTPS pools that have been idle for longer than the specified timeout.
§Arguments
timeout- Duration after which connections are considered idle
Sourcepub async fn connect_http(
&self,
authority: &str,
) -> Result<Cacheable<PooledConn<SendRequest<T>>>, ErrorCode>
pub async fn connect_http( &self, authority: &str, ) -> Result<Cacheable<PooledConn<SendRequest<T>>>, ErrorCode>
Attempts to get an HTTP connection for the specified authority.
If a cached connection is available, it will be returned as a Hit.
Otherwise, a new connection will be established and returned as a Miss.
§Arguments
authority- The authority (host:port) to connect to
§Returns
A cacheable connection or an error if the connection fails
Sourcepub async fn connect_https(
&self,
tls: &TlsConnector,
authority: &str,
) -> Result<Cacheable<PooledConn<SendRequest<T>>>, ErrorCode>
pub async fn connect_https( &self, tls: &TlsConnector, authority: &str, ) -> Result<Cacheable<PooledConn<SendRequest<T>>>, ErrorCode>
Attempts to get an HTTPS connection for the specified authority.
If a cached connection is available, it will be returned as a Hit.
Otherwise, a new connection will be established and returned as a Miss.
§Arguments
tls- The TLS connector to use for establishing secure connectionsauthority- The authority (host:port) to connect to
§Returns
A cacheable connection or an error if the connection fails
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ConnPool<T>
impl<T> !RefUnwindSafe for ConnPool<T>
impl<T> Send for ConnPool<T>where
T: Send,
impl<T> Sync for ConnPool<T>where
T: Send,
impl<T> Unpin for ConnPool<T>
impl<T> !UnwindSafe for ConnPool<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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>
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>
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