pub struct ProviderGate { /* private fields */ }Expand description
Bulkhead plus circuit breaker guarding one provider.
Implementations§
Source§impl ProviderGate
impl ProviderGate
Sourcepub fn new(limits: ProviderLimits) -> Result<Self, String>
pub fn new(limits: ProviderLimits) -> Result<Self, String>
Gate for validated limits.
Sourcepub fn try_acquire(
&self,
tenant_id: &str,
priority: WorkPriority,
now: Instant,
) -> Result<ProviderPermit, ProviderBlock>
pub fn try_acquire( &self, tenant_id: &str, priority: WorkPriority, now: Instant, ) -> Result<ProviderPermit, ProviderBlock>
Acquire a permit for tenant at priority.
Sourcepub fn record_success(&self, permit: ProviderPermit)
pub fn record_success(&self, permit: ProviderPermit)
Return a permit after success; closes a half-open circuit.
Sourcepub fn record_failure(&self, permit: ProviderPermit, now: Instant)
pub fn record_failure(&self, permit: ProviderPermit, now: Instant)
Return a permit after failure; may open the circuit.
Sourcepub fn release(&self, permit: ProviderPermit)
pub fn release(&self, permit: ProviderPermit)
Give capacity back without judging the provider. Use this when the caller failed before or after the provider ran (store conflict, stale claim) so infrastructure errors do not trip the provider’s circuit.
Auto Trait Implementations§
impl !Freeze for ProviderGate
impl RefUnwindSafe for ProviderGate
impl Send for ProviderGate
impl Sync for ProviderGate
impl Unpin for ProviderGate
impl UnsafeUnpin for ProviderGate
impl UnwindSafe for ProviderGate
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