pub struct BackpressureTracker { /* private fields */ }Expand description
Per-peer receiver-side back-pressure state.
Sibling field on PeerState per
bb-runtime/src/framework/peer_state.rs. The tracker is
receiver-state-only; sender-side back-off lives in the existing
BackoffTable.
Implementations§
Source§impl BackpressureTracker
impl BackpressureTracker
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a fresh tracker with the spec’s defaults (high-water = 75%, K = 3, min-notice-interval = 1 second).
Sourcepub fn with_config(
high_water_mark_pct: u8,
notice_threshold_k: u32,
min_notice_interval_ns: u64,
) -> Self
pub fn with_config( high_water_mark_pct: u8, notice_threshold_k: u32, min_notice_interval_ns: u64, ) -> Self
Construct a tracker with custom config values. high_water_mark_pct
is clamped to 1..=100; notice_threshold_k is clamped to
at least 1; min_notice_interval_ns is clamped to at least 1.
Sourcepub fn high_water_mark_pct(&self) -> u8
pub fn high_water_mark_pct(&self) -> u8
High-water mark threshold as a percentage.
Sourcepub fn is_over_high_water(&self, len: usize, capacity: usize) -> bool
pub fn is_over_high_water(&self, len: usize, capacity: usize) -> bool
Whether the supplied queue depth (len) crosses the
configured high-water mark for the supplied capacity.
Sourcepub fn notice_threshold_k(&self) -> u32
pub fn notice_threshold_k(&self) -> u32
K threshold (notices-without-recovery before silent-drop).
Sourcepub fn min_notice_interval_ns(&self) -> u64
pub fn min_notice_interval_ns(&self) -> u64
Minimum interval enforced between successive notices to the same peer.
Sourcepub fn is_silent_drop_active(&self, peer: PeerId) -> bool
pub fn is_silent_drop_active(&self, peer: PeerId) -> bool
Whether the peer is currently in silent-drop mode.
Sourcepub fn entry(&self, peer: PeerId) -> Option<BackpressureEntry>
pub fn entry(&self, peer: PeerId) -> Option<BackpressureEntry>
Inspect the recorded entry for peer. Returns None when
no overload event has been observed for this peer yet.
Sourcepub fn iter(&self) -> impl Iterator<Item = (PeerId, BackpressureEntry)> + '_
pub fn iter(&self) -> impl Iterator<Item = (PeerId, BackpressureEntry)> + '_
Iterate (PeerId, BackpressureEntry) for snapshot capture.
Sourcepub fn observe_overload(
&mut self,
peer: PeerId,
cause: BackoffCause,
min_backoff_ns: u64,
now_ns: u64,
) -> Decision
pub fn observe_overload( &mut self, peer: PeerId, cause: BackoffCause, min_backoff_ns: u64, now_ns: u64, ) -> Decision
Observe an overload condition for peer at now_ns.
Returns:
Decision::SilentDropif the peer is already in silent-drop mode. The caller drops the envelope; no notice is emitted.Decision::Suppressif a recent notice’s quoted back-off window has not yet elapsed (duplicate suppression).Decision::EmitNoticeif the caller should emit a notice. The tracker incrementsnotices_sent+ records the emission timestamp + back-off. If this push crosses the K threshold, the entry transitions tosilent_drop_activein the next observation - the current decision still emits the K-th notice so the sender gets the final warning before silent drop kicks in.
min_backoff_ns is the back-off duration the caller intends
to quote on the notice. The tracker uses it for the
duplicate-suppression window. A 0 value collapses to the
configured min_notice_interval_ns floor.
Sourcepub fn record_recovery(&mut self, peer: PeerId)
pub fn record_recovery(&mut self, peer: PeerId)
Record that the sender has recovered (e.g., φ-accrual
transitioned back to Live). Resets the per-peer counter
and clears silent_drop_active. The next observe_overload
for the peer starts fresh.
Sourcepub fn in_suppression_window(&self, peer: PeerId, now_ns: u64) -> bool
pub fn in_suppression_window(&self, peer: PeerId, now_ns: u64) -> bool
Whether peer is currently inside its duplicate-suppression
window. Used by tests + introspection.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BackpressureTracker
impl RefUnwindSafe for BackpressureTracker
impl Send for BackpressureTracker
impl Sync for BackpressureTracker
impl Unpin for BackpressureTracker
impl UnsafeUnpin for BackpressureTracker
impl UnwindSafe for BackpressureTracker
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedComponent for 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> 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