Crate bb8_failsafe

source
Expand description

thin wapper of failsafe-rs to provide circuit breaker captilites to bb8.

§Example

Using an imaginary “foodb” database.

#[tokio::main]
async fn main() {
    let manager = bb8_foodb::FooConnectionManager::new("localhost:1234");
    let circuitbreaker = bb8_failsafe::failsafe::Config::new().build();
    let safemanager = bb8_failsafe::FailsafeConnectionManager::new(manager, circuitbreaker);
    let pool = bb8::Pool::builder().build(safemanager).await.unwrap();

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

Re-exports§

Structs§