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

bb8-failsafe

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

13 releases

new 0.1.12 Jun 15, 2024
0.1.10 Apr 1, 2024
0.1.9 Mar 25, 2024
0.1.4 Dec 27, 2023
0.1.1 May 23, 2022

#2 in #bb8

Download history 33/week @ 2024-02-22 1/week @ 2024-02-29 122/week @ 2024-03-14 144/week @ 2024-03-21 153/week @ 2024-03-28 32/week @ 2024-04-04 2/week @ 2024-04-11 156/week @ 2024-05-30 35/week @ 2024-06-06

191 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
~95K SLoC