pub struct BackpressureEnforcer { /* private fields */ }Expand description
Enforces a maximum number of in-flight jobs per topic.
Implementations§
Source§impl BackpressureEnforcer
impl BackpressureEnforcer
Sourcepub fn new(max_inflight: usize) -> Self
pub fn new(max_inflight: usize) -> Self
Creates an enforcer with a global maximum of max_inflight concurrent
in-flight jobs.
Sourcepub async fn try_enqueue<Q: Queue + ?Sized>(
&self,
queue: &Q,
topic: &str,
payload: Vec<u8>,
) -> Result<(), BackpressureError>
pub async fn try_enqueue<Q: Queue + ?Sized>( &self, queue: &Q, topic: &str, payload: Vec<u8>, ) -> Result<(), BackpressureError>
Attempts to acquire a backpressure slot non-blockingly. Returns Err if at capacity.
Sourcepub fn inc_delivered(&self, topic: &str)
pub fn inc_delivered(&self, topic: &str)
Increments the in-flight counter when a job is delivered.
Sourcepub fn dec_finished(&self, topic: &str)
pub fn dec_finished(&self, topic: &str)
Decrements the in-flight counter after a job is acked/nacked.
Auto Trait Implementations§
impl Freeze for BackpressureEnforcer
impl RefUnwindSafe for BackpressureEnforcer
impl Send for BackpressureEnforcer
impl Sync for BackpressureEnforcer
impl Unpin for BackpressureEnforcer
impl UnsafeUnpin for BackpressureEnforcer
impl UnwindSafe for BackpressureEnforcer
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