pub struct BackpressureController { /* private fields */ }Expand description
Adaptive backpressure controller implementing multiple mitigation strategies.
Implementations§
Source§impl BackpressureController
impl BackpressureController
Sourcepub fn new(config: BackpressureConfig) -> Self
pub fn new(config: BackpressureConfig) -> Self
Create a new controller with the supplied configuration.
Sourcepub fn try_accept(&mut self, now_ms: u64) -> BackpressureDecision
pub fn try_accept(&mut self, now_ms: u64) -> BackpressureDecision
Attempt to accept one item at now_ms (monotonic milliseconds).
Updates internal state and returns the decision the caller should act on.
Sourcepub fn record_dequeue(&mut self)
pub fn record_dequeue(&mut self)
Record that one item was consumed from the queue.
Sourcepub fn stats(&self) -> &BackpressureStats
pub fn stats(&self) -> &BackpressureStats
Return a reference to the current statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset all counters (peak_queue_depth, items_dropped, …) without changing the queue depth or backpressure state.
Sourcepub fn is_above_high_watermark(&self) -> bool
pub fn is_above_high_watermark(&self) -> bool
Return true when the current depth is at or above the high watermark.
Sourcepub fn is_below_low_watermark(&self) -> bool
pub fn is_below_low_watermark(&self) -> bool
Return true when the current depth is at or below the low watermark.
Sourcepub fn replenish_tokens(&mut self, now_ms: u64)
pub fn replenish_tokens(&mut self, now_ms: u64)
Replenish the token bucket based on elapsed time since the last tick.
Only effective when the strategy is Throttle.
Sourcepub fn current_depth(&self) -> usize
pub fn current_depth(&self) -> usize
Return the current logical queue depth.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BackpressureController
impl RefUnwindSafe for BackpressureController
impl Send for BackpressureController
impl Sync for BackpressureController
impl Unpin for BackpressureController
impl UnsafeUnpin for BackpressureController
impl UnwindSafe for BackpressureController
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.