async_bulkhead/
lib.rs

1//! An async semaphore-based bulkhead implementation.
2//!
3//! The [`Bulkhead`] struct provides a `limit` method for wrapping
4//! futures with the bulkhead client-side resiliency pattern.
5//!
6//! ### Example
7//! ```rust
8//! use async_bulkhead::Bulkhead;
9//! use async_bulkhead::BulkheadError;
10//! use std::time::Duration;
11//!
12//! let bulkhead = Bulkhead::builder()
13//!     .max_concurrent_calls(10)
14//!     .max_wait_duration(Duration::from_millis(100))
15//!     .build()
16//!     .expect("max concurrent calls not > 0");
17//!
18//! async {
19//!     let value = bulkhead.limit(async { 10 }).await?;
20//!     println!("{value}");
21//!     Ok::<_, BulkheadError>(())
22//! };
23//! ```
24//!
25//! ### Features
26//! Note that the runtime features of this crate are mutually exclusive.
27//! You should only use one of the following:
28//! 1. `rt-tokio` (default)
29//! 1. `rt-async-std`
30//! 1. `rt-smol`
31
32mod bulkhead;
33pub use bulkhead::*;