#circuit-breaker #bb8 #thin #wapper #async #captilites #failsafe-rs

bb8-failsafe

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

12 releases

new 0.1.11 Jun 2, 2024
0.1.10 Apr 1, 2024
0.1.9 Mar 25, 2024
0.1.7 Feb 5, 2024
0.1.1 May 23, 2022

#1 in #bb8

Download history 4/week @ 2024-02-04 38/week @ 2024-02-18 10/week @ 2024-02-25 139/week @ 2024-03-17 139/week @ 2024-03-24 167/week @ 2024-03-31 8/week @ 2024-04-07

883 downloads per month

MIT license

7KB
114 lines

bb8-failsafe

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


lib.rs:

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.
        });
    }
}

Dependencies

~4–11MB
~96K SLoC