pub struct BackpressureController { /* private fields */ }Expand description
Backpressure controller for automatic rate limiting
Implementations§
Source§impl BackpressureController
impl BackpressureController
pub fn new(config: BackpressureConfig) -> Self
Sourcepub fn should_admit(&self) -> bool
pub fn should_admit(&self) -> bool
Check if we should admit a new task
Sourcepub fn on_enqueue(&self) -> bool
pub fn on_enqueue(&self) -> bool
Increment queue size when a task is enqueued
Sourcepub fn on_complete(&self)
pub fn on_complete(&self)
Decrement queue size when a task completes
Sourcepub fn update_rate(&self, observed_latency_ms: u64)
pub fn update_rate(&self, observed_latency_ms: u64)
Update throttle rate based on observed latency
Sourcepub fn current_rate(&self) -> f64
pub fn current_rate(&self) -> f64
Get current throttle rate (tasks per second)
Sourcepub fn queue_size(&self) -> usize
pub fn queue_size(&self) -> usize
Get current queue size
Sourcepub fn compute_delay(&self) -> Option<Duration>
pub fn compute_delay(&self) -> Option<Duration>
Calculate delay needed before next task admission
Sourcepub fn set_max_queue_size(&self, size: usize)
pub fn set_max_queue_size(&self, size: usize)
Adjust max queue size dynamically
Trait Implementations§
Source§impl Debug for BackpressureController
impl Debug for BackpressureController
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> 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