pub struct DegradationController<M: ResourceMonitor> { /* private fields */ }Expand description
Graceful degradation controller that wraps a ResourceMonitor and
makes admission-control decisions.
Implementations§
Source§impl<M: ResourceMonitor> DegradationController<M>
impl<M: ResourceMonitor> DegradationController<M>
Sourcepub fn new(monitor: M, elevated_batch_factor: f64) -> Self
pub fn new(monitor: M, elevated_batch_factor: f64) -> Self
Create a new controller with the given resource monitor.
elevated_batch_factor is multiplied by the normal batch size when
pressure is elevated (e.g. 0.5 halves the batch).
Sourcepub fn pressure(&self) -> PressureLevel
pub fn pressure(&self) -> PressureLevel
Return the current pressure level.
Sourcepub fn elevated_batch_factor(&self) -> f64
pub fn elevated_batch_factor(&self) -> f64
Return the elevated batch factor.
Sourcepub fn admit_spawn(&self) -> DegradationDecision
pub fn admit_spawn(&self) -> DegradationDecision
Decide whether a new child actor spawn should be admitted.
Sourcepub fn effective_batch_size(&self, normal: usize) -> usize
pub fn effective_batch_size(&self, normal: usize) -> usize
Compute the effective batch size given normal and current pressure.
Sourcepub fn should_pause_non_essential(&self) -> bool
pub fn should_pause_non_essential(&self) -> bool
Decide whether a non-essential actor should be paused.
Auto Trait Implementations§
impl<M> Freeze for DegradationController<M>where
M: Freeze,
impl<M> RefUnwindSafe for DegradationController<M>where
M: RefUnwindSafe,
impl<M> Send for DegradationController<M>
impl<M> Sync for DegradationController<M>
impl<M> Unpin for DegradationController<M>where
M: Unpin,
impl<M> UnsafeUnpin for DegradationController<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for DegradationController<M>where
M: UnwindSafe,
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
Mutably borrows from an owned value. Read more