5 releases
0.1.4 | Mar 8, 2020 |
---|---|
0.1.3 | Mar 8, 2020 |
0.1.2 | Mar 8, 2020 |
0.1.1 | Mar 8, 2020 |
0.1.0 | Mar 8, 2020 |
#2218 in Asynchronous
17KB
416 lines
mpool
A generic connection pool for Rust.
License
Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
lib.rs
:
A generic connection pool.
Implementors of the ManageConnection
trait provide the specific
logic to create and check the health of connections.
Example
use std::io;
use std::net::SocketAddr;
use async_trait::async_trait;
use mpool::{ManageConnection, Pool};
use tokio::net::TcpStream;
struct MyPool {
addr: SocketAddr,
}
#[async_trait]
impl ManageConnection for MyPool {
type Connection = TcpStream;
async fn connect(&self) -> io::Result<Self::Connection> {
TcpStream::connect(self.addr).await
}
async fn check(&self, _conn: &mut Self::Connection) -> io::Result<()> {
Ok(())
}
}
Dependencies
~4MB
~67K SLoC