pub struct BackpressureController { /* private fields */ }Expand description
Per-subscription backpressure controller.
Tracks the backpressure strategy and dropped event count for a single subscription. The dispatcher consults this controller before sending each event to determine whether it should be delivered or dropped.
Implementations§
Source§impl BackpressureController
impl BackpressureController
Sourcepub fn new(strategy: BackpressureStrategy) -> Self
pub fn new(strategy: BackpressureStrategy) -> Self
Creates a new controller with the given strategy.
Sourcepub fn with_lag_threshold(
strategy: BackpressureStrategy,
threshold: u64,
) -> Self
pub fn with_lag_threshold( strategy: BackpressureStrategy, threshold: u64, ) -> Self
Creates a new controller with a custom lag warning threshold.
Sourcepub fn should_deliver(&mut self) -> bool
pub fn should_deliver(&mut self) -> bool
Determines whether the next event should be delivered.
For Sample(n), increments an internal counter and returns true
every Nth call. For other strategies, always returns true — the
actual backpressure is handled by the broadcast channel or the
dispatcher’s send logic.
Sourcepub fn record_drop(&mut self)
pub fn record_drop(&mut self)
Records an event drop (e.g., DropNewest when buffer is full).
Sourcepub fn strategy(&self) -> BackpressureStrategy
pub fn strategy(&self) -> BackpressureStrategy
Returns the configured backpressure strategy.
Sourcepub fn lag_warning_threshold(&self) -> u64
pub fn lag_warning_threshold(&self) -> u64
Returns the lag warning threshold.
Sourcepub fn is_lagging(&self, lag: u64) -> bool
pub fn is_lagging(&self, lag: u64) -> bool
Returns true if the given lag exceeds the warning threshold.
Auto Trait Implementations§
impl Freeze for BackpressureController
impl RefUnwindSafe for BackpressureController
impl Send for BackpressureController
impl Sync for BackpressureController
impl Unpin for BackpressureController
impl UnwindSafe for BackpressureController
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.