pub struct AsyncGuardAdapter<E>where
E: ExternalGuard + ?Sized,{ /* private fields */ }Expand description
Adapter that composes circuit breaker + token bucket + TTL cache + retry
on top of an ExternalGuard.
Flow of a single evaluate call:
- Check the circuit breaker. If open, return
CircuitOpenVerdictwithout calling the inner guard. - Check the cache. On hit, return the cached verdict without calling the inner guard.
- Check the token bucket. If empty, return
RateLimitedVerdict. Rate-limited calls do not increment the circuit breaker. - Call the inner guard via
retry_with_jitter. - Record success/failure on the breaker. On success, cache the verdict.
Implementations§
Source§impl<E> AsyncGuardAdapter<E>where
E: ExternalGuard + ?Sized,
impl<E> AsyncGuardAdapter<E>where
E: ExternalGuard + ?Sized,
Sourcepub fn builder(inner: Arc<E>) -> AsyncGuardAdapterBuilder<E>
pub fn builder(inner: Arc<E>) -> AsyncGuardAdapterBuilder<E>
Start a builder with defaults.
Sourcepub fn config(&self) -> &AsyncGuardAdapterConfig
pub fn config(&self) -> &AsyncGuardAdapterConfig
Effective configuration.
Sourcepub fn circuit_state(&self) -> CircuitState
pub fn circuit_state(&self) -> CircuitState
Inspect the circuit breaker state (primarily for tests and metrics).
Sourcepub async fn evaluate(&self, ctx: &GuardCallContext) -> Verdict
pub async fn evaluate(&self, ctx: &GuardCallContext) -> Verdict
Evaluate the request end-to-end.
Auto Trait Implementations§
impl<E> !Freeze for AsyncGuardAdapter<E>
impl<E> !RefUnwindSafe for AsyncGuardAdapter<E>
impl<E> Send for AsyncGuardAdapter<E>where
E: ?Sized,
impl<E> Sync for AsyncGuardAdapter<E>where
E: ?Sized,
impl<E> Unpin for AsyncGuardAdapter<E>where
E: ?Sized,
impl<E> UnsafeUnpin for AsyncGuardAdapter<E>where
E: ?Sized,
impl<E> !UnwindSafe for AsyncGuardAdapter<E>
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