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

bb8-failsafe

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

11 releases

0.1.10 Apr 1, 2024
0.1.9 Mar 25, 2024
0.1.7 Feb 5, 2024
0.1.6 Jan 9, 2024
0.1.1 May 23, 2022

#1 in #bb8

Download history 11/week @ 2024-01-03 1/week @ 2024-01-10 4/week @ 2024-01-31 10/week @ 2024-02-14 34/week @ 2024-02-21 4/week @ 2024-02-28 107/week @ 2024-03-13 156/week @ 2024-03-20 138/week @ 2024-03-27 48/week @ 2024-04-03 4/week @ 2024-04-10

367 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
~97K SLoC