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