pub struct TrialGuard<'b> { /* private fields */ }Expand description
RAII guard for one admitted pull-through attempt.
Returned inside Admission::Proceed by OriginBreaker::acquire.
It exists to make the HALF-OPEN trial budget cancellation-safe: a
half-open trial reserves a half_open_in_flight slot at admission,
and that slot must be returned even if the surrounding async fetch is
cancelled (client disconnect / timeout) before its outcome is known.
Resolution happens exactly one of two ways:
TrialGuard::recordcommits the outcome — driving the CLOSED→OPEN, HALF-OPEN→CLOSED, and HALF-OPEN→OPEN transitions — and defuses the guard soDropdoes nothing.- The guard is dropped without
record(the future was cancelled):Dropreleases the reserved HALF-OPEN slot (a no-op for a CLOSED admission, which reserves no slot) without recording any state transition. The breaker neither closes nor re-opens on a cancelled trial — it simply reclaims the budget so a later trial is admitted.
The guard borrows the breaker, so it cannot outlive it; the engine holds each breaker for the whole pull-through call, which strictly outlives the guard.
Implementations§
Source§impl TrialGuard<'_>
impl TrialGuard<'_>
Sourcepub fn record(self, outcome: OriginOutcome)
pub fn record(self, outcome: OriginOutcome)
Commit the outcome of the admitted attempt and defuse the guard.
Drives the breaker’s state transitions (the private
OriginBreaker::record_committed) and clears owns_slot so the
guard’s Drop does not also release the HALF-OPEN slot — record
already accounts for the slot it resolves. For an inert guard
(disabled policy) this is a no-op.
Trait Implementations§
Source§impl<'b> Debug for TrialGuard<'b>
impl<'b> Debug for TrialGuard<'b>
Source§impl Drop for TrialGuard<'_>
impl Drop for TrialGuard<'_>
Auto Trait Implementations§
impl<'b> !RefUnwindSafe for TrialGuard<'b>
impl<'b> !UnwindSafe for TrialGuard<'b>
impl<'b> Freeze for TrialGuard<'b>
impl<'b> Send for TrialGuard<'b>
impl<'b> Sync for TrialGuard<'b>
impl<'b> Unpin for TrialGuard<'b>
impl<'b> UnsafeUnpin for TrialGuard<'b>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more