pub struct ResponsePermit { /* private fields */ }Expand description
Reservation for the downstream response-capture worker job. Draws
from a distinct capacity semaphore so operators can tell via
av_events_dropped_total{stage="response_slot"} vs
stage="worker_queue" which class of admission is the bottleneck.
Unlike WorkerPermit, the response permit only holds the
capacity semaphore — the mpsc queue slot is re-acquired at submit
time via Self::submit. This keeps the initial admission cheap
(one semaphore acquire instead of two mpsc reservations that would
otherwise compete for the same shard’s slot with the worker
permit) and lets the response job land whenever worker capacity
and the shard have room, which is the common case since response
capture happens
tens-of-seconds after the initial worker job has drained.
Held by the streaming-response wrapper in routes.rs
(AbortFinalizingStream) for the lifetime of the forwarded response;
drops on stream completion or client abort.
Implementations§
Source§impl ResponsePermit
impl ResponsePermit
Sourcepub fn submit(
self,
worker: &WorkerHandle,
job: WorkerJob,
) -> Result<(), SubmitError>
pub fn submit( self, worker: &WorkerHandle, job: WorkerJob, ) -> Result<(), SubmitError>
Commit a response-capture job. The capacity slot reserved at
admission travels INTO the envelope: the submission never
contends on the main worker semaphore, so a backlog of new
admissions cannot starve the capture job of an
already-admitted stream — the guarantee try_reserve_pair’s
acquire-both-or-fail exists to provide. (A previous revision
dropped this permit and drew a fresh slot from the WORKER
semaphore, which both forfeited the reservation under load and
charged the resulting drop to stage="response_slot" when the
exhausted budget was actually worker capacity.) The only
remaining failure mode is the shard’s bounded mpsc queue being
momentarily full, which returns SubmitError::Full and bumps
av_events_dropped_total{stage="response_slot"}.
Auto Trait Implementations§
impl Freeze for ResponsePermit
impl !RefUnwindSafe for ResponsePermit
impl Send for ResponsePermit
impl Sync for ResponsePermit
impl Unpin for ResponsePermit
impl UnsafeUnpin for ResponsePermit
impl !UnwindSafe for ResponsePermit
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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> 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