mobc 0.3.0

A generic connection pool, but async/await
Documentation

mobc

A generic connection pool, but async/.await

Build Status crates.io

Documentation

Note: mobc requires at least Rust 1.39.

Features

  • Support async/.await syntax.
  • Support tokio 0.2 and async-std 1.0 runtimes.
  • Simple and fast customization

Adapter

Usage

If you are using tokio 0.2-alpha.6, use mobc 0.2.10.

[dependencies]
mobc = "0.3.0"

foo demo

use tokio;

#[tokio::main]
async fn main() {
    let manager = mobc_foodb::FooConnectionManager::new("localhost:1234");
    let pool = mobc::Pool::builder()
        .max_size(15)
        .build(manager)
        .await
        .unwrap();

    for _ in 0..20 {
        let pool = pool.clone();
        tokio::spawn(async {
            let conn = pool.get().await.unwrap();
            // use the connection
            // it will be returned to the pool when it falls out of scope.
        });
    }
}