pub struct LoadShedController { /* private fields */ }Expand description
The serve path’s load-shed handle: a swappable policy over live meters.
Implementations§
Source§impl LoadShedController
impl LoadShedController
Sourcepub fn from_config(cfg: &ResolvedLoadShed) -> Arc<Self> ⓘ
pub fn from_config(cfg: &ResolvedLoadShed) -> Arc<Self> ⓘ
Build a controller with the policy cfg selects, a fresh in-flight
counter, and an unseeded egress meter.
Sourcepub fn try_admit(
&self,
class: RequestClass,
client: B256,
) -> Result<ShedSlot, ShedReason>
pub fn try_admit( &self, class: RequestClass, client: B256, ) -> Result<ShedSlot, ShedReason>
Decide and, on admit, take a slot. On shed returns the reason; the caller
maps it to the NotFound-shaped refusal.
Sourcepub fn record_egress(&self, bytes: u64)
pub fn record_egress(&self, bytes: u64)
Feed delivered bytes into the egress meter (delivery hot path). bytes
is the per-chunk length also added to the billed delivered counter —
the bao-stream content plus interleaved proof, not the full QUIC frame.
Sourcepub fn sample_egress(&self, interval_secs: u64) -> u64
pub fn sample_egress(&self, interval_secs: u64) -> u64
Fold the interval’s bytes into the egress EWMA; returns the new bytes/sec (for the gauge).
Sourcepub fn pressure_active(&self) -> bool
pub fn pressure_active(&self) -> bool
Whether the active policy currently considers the node pressured (gauge).
Sourcepub fn node_in_flight(&self) -> u32
pub fn node_in_flight(&self) -> u32
Node-wide serves in flight, for the decdn_load_shed_streams_in_flight
gauge. Reads the same live counter try_admit feeds into the pressure
snapshot, so the gauge tracks exactly what the policy decides against.
Sourcepub fn reload(&self, cfg: &ResolvedLoadShed)
pub fn reload(&self, cfg: &ResolvedLoadShed)
Swap in a policy rebuilt from a new resolved config. Live counters and the egress meter are preserved; only the decision policy changes.
Auto Trait Implementations§
impl !Freeze for LoadShedController
impl !RefUnwindSafe for LoadShedController
impl !UnwindSafe for LoadShedController
impl Send for LoadShedController
impl Sync for LoadShedController
impl Unpin for LoadShedController
impl UnsafeUnpin for LoadShedController
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§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>
T in a tonic::Request