pub struct WatermarkController<C = MonotonicClock>where
C: Clock,{ /* private fields */ }Expand description
Per-pipeline-thread pause/resume state machine with hysteresis.
The controller never calls anything: WatermarkController::tick
returns a Transition and the driver applies it, which keeps this
module free of source and metrics dependencies. Transitions strictly
alternate (Pause, Resume, Pause, …) and each full cycle takes at
least BackpressureParams::min_pause.
Implementations§
Source§impl WatermarkController
impl WatermarkController
Sourcepub fn new(params: BackpressureParams) -> WatermarkController
pub fn new(params: BackpressureParams) -> WatermarkController
Controller on the real monotonic clock.
Source§impl<C> WatermarkController<C>where
C: Clock,
impl<C> WatermarkController<C>where
C: Clock,
Sourcepub fn with_clock(
params: BackpressureParams,
clock: C,
) -> WatermarkController<C>
pub fn with_clock( params: BackpressureParams, clock: C, ) -> WatermarkController<C>
Controller with an injected clock (tests).
Sourcepub fn on_send_rejected(&mut self)
pub fn on_send_rejected(&mut self)
Record that a try_send to a downstream queue was rejected. Cheap;
call from the poll loop’s rejection path. While paused this restarts
the minimum-pause timer — a rejection is proof downstream is still
congested.
Sourcepub fn tick(
&mut self,
budget: &InflightBudget,
queues_below_low: bool,
) -> Option<Transition>
pub fn tick( &mut self, budget: &InflightBudget, queues_below_low: bool, ) -> Option<Transition>
Evaluate the state machine once per poll iteration.
queues_below_low is the driver’s view of its downstream queues
(all below the low-watermark fill ratio). Returns a transition for
the driver to apply, or None.
Sourcepub fn params(&self) -> &BackpressureParams
pub fn params(&self) -> &BackpressureParams
The hysteresis parameters in force.
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for WatermarkController<C>where
C: Freeze,
impl<C> RefUnwindSafe for WatermarkController<C>where
C: RefUnwindSafe,
impl<C> Send for WatermarkController<C>where
C: Send,
impl<C> Sync for WatermarkController<C>where
C: Sync,
impl<C> Unpin for WatermarkController<C>where
C: Unpin,
impl<C> UnsafeUnpin for WatermarkController<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for WatermarkController<C>where
C: UnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more