pub struct Bulkhead { /* private fields */ }Expand description
Limits concurrent executions to max_concurrent using a semaphore.
Acquire a permit before starting a unit of work. If no permits are
available the call returns Err immediately (non-blocking).
§Panics
This type never panics.
Implementations§
Source§impl Bulkhead
impl Bulkhead
Sourcepub fn acquire(&self) -> Result<BulkheadPermit, OrchestratorError>
pub fn acquire(&self) -> Result<BulkheadPermit, OrchestratorError>
Attempts to acquire a permit without blocking.
§Returns
Ok(BulkheadPermit)— a slot was available and has been reserved.Err(OrchestratorError::Other(_))— all slots are currently occupied.
The error message includes the bulkhead name and the configured limit, so callers can log it without additional context.
Sourcepub fn max_concurrent(&self) -> usize
pub fn max_concurrent(&self) -> usize
Returns the maximum number of concurrent permits.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Returns the number of permits currently available (not held).
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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request