| Crates.io | connpool |
| lib.rs | connpool |
| version | 0.2.0 |
| created_at | 2025-12-28 21:41:18.921706+00 |
| updated_at | 2025-12-29 09:10:12.146526+00 |
| description | A concurrent, generic connection pool for Rust |
| homepage | |
| repository | https://github.com/ferronweb/connpool |
| max_upload_size | |
| id | 2009441 |
| size | 31,497 |
connpool - a concurrent, generic connection pool for Rustconnpool is a high-performance, generic connection pool crate designed for Rust applications.
It provides a thread-safe, asynchronous pool for managing and reusing connections (or any other resource)
with both global and local (per-key) limits.
Arc and RwLock for thread-safe operations.Eq + Hash.use connpool::Pool;
#[tokio::main]
async fn main() {
// Create a new pool with a global limit of 10 connections
let pool = Pool::new(10);
// Pull a connection for a specific key
let item = pool.pull("my_key").await;
// Use the connection
if let Some(value) = item.inner() {
let value: usize = *value;
println!("Got value: {:?}", value);
}
// The connection is automatically returned to the pool when `item` is dropped
// Alternatively, drop the connection
let _ = item.take();
}
pull_with_local_limit for fine-grained control over local limits.This project is licensed under the MIT License.