pub struct BackpressureConfig {
pub max_buffered_chunks: usize,
pub high_watermark: f64,
pub low_watermark: f64,
pub strategy: BackpressureStrategy,
}Expand description
Backpressure configuration for stream processing.
Fields§
§max_buffered_chunks: usizeMaximum number of buffered chunks before backpressure activates.
high_watermark: f64High watermark as a fraction of max_buffered_chunks (0.0–1.0).
Backpressure activates when the buffer exceeds this fraction.
low_watermark: f64Low watermark as a fraction (0.0–1.0). Normal processing resumes when the buffer drops below this fraction.
strategy: BackpressureStrategyStrategy to apply when the buffer is full.
Implementations§
Source§impl BackpressureConfig
impl BackpressureConfig
Sourcepub fn new(max_buffered: usize) -> Self
pub fn new(max_buffered: usize) -> Self
Create a new BackpressureConfig with sensible defaults.
Defaults: high_watermark=0.8, low_watermark=0.2, strategy=Block.
Sourcepub fn with_watermarks(self, high: f64, low: f64) -> Self
pub fn with_watermarks(self, high: f64, low: f64) -> Self
Override the high and low watermark fractions.
Sourcepub fn with_strategy(self, strategy: BackpressureStrategy) -> Self
pub fn with_strategy(self, strategy: BackpressureStrategy) -> Self
Override the backpressure strategy.
Sourcepub fn is_above_high_watermark(&self, current_buffered: usize) -> bool
pub fn is_above_high_watermark(&self, current_buffered: usize) -> bool
Returns true when the current buffer level exceeds the high watermark.
Sourcepub fn is_below_low_watermark(&self, current_buffered: usize) -> bool
pub fn is_below_low_watermark(&self, current_buffered: usize) -> bool
Returns true when the current buffer level is below the low watermark.
Sourcepub fn should_apply_backpressure(&self, current_buffered: usize) -> bool
pub fn should_apply_backpressure(&self, current_buffered: usize) -> bool
Returns true when backpressure should be applied (buffer is above the high watermark).
Trait Implementations§
Source§impl Clone for BackpressureConfig
impl Clone for BackpressureConfig
Source§fn clone(&self) -> BackpressureConfig
fn clone(&self) -> BackpressureConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BackpressureConfig
impl RefUnwindSafe for BackpressureConfig
impl Send for BackpressureConfig
impl Sync for BackpressureConfig
impl Unpin for BackpressureConfig
impl UnsafeUnpin for BackpressureConfig
impl UnwindSafe for BackpressureConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more