Expand description
§ReqwestManagementPool
A client management pool based on Reqwest and Tokio ensures that clients with different configurations can be reused, reducing memory consumption.
§Features
- Automatically manages the reqwest client connection pool
- Supports connection reuse, improving performance
- Automatically releases and cleans up idle connections
- Thread-safe, supporting concurrent access
- Automatically expands and shrinks the pool size
§Usage Examples
use reqwest_management_pool::ClientPool;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create and initialize the connection pool
let pool = ClientPool::new();
// Get clients from the pool
if let Some(client) = pool.malloc().await {
// Send a request using the client.
let response = client.get()
.get("https://example.com")
.send()
.await?;
// The client will automatically release it back into the pool when the scope ends.
}
Ok(())
}§Configuration
Structs§
- Client
Pool - The main structure for the HTTP client management pool
- Pooled
Client Inner - A smart wrapper for a borrowed client. Returns to pool automatically on Drop.