pub struct Bulkhead { /* private fields */ }
Expand description
A semaphore-based bulkhead for limiting the number of concurrent calls to a resource.
This type can be safely cloned and sent across threads while maintaining the correct number of allowed concurrent calls.
Implementations§
Source§impl Bulkhead
impl Bulkhead
Sourcepub async fn limit<F, R>(&self, f: F) -> Result<R, BulkheadError>where
F: Future<Output = R>,
pub async fn limit<F, R>(&self, f: F) -> Result<R, BulkheadError>where
F: Future<Output = R>,
Limits the number of concurrent calls using a semaphore with the specified maximum concurrent calls and semaphore wait duration.
When the semaphore permit can’t be acquired before the specified duration,
the Err(BulkheadError::Timeout)
value is returned.
Source§impl Bulkhead
impl Bulkhead
Sourcepub fn builder() -> BulkheadBuilder
pub fn builder() -> BulkheadBuilder
Creates a new BulkheadBuilder
containing the default configuration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bulkhead
impl RefUnwindSafe for Bulkhead
impl Send for Bulkhead
impl Sync for Bulkhead
impl Unpin for Bulkhead
impl UnwindSafe for Bulkhead
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more