pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter for intake events
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(
max_per_minute: usize,
max_concurrent: usize,
backoff_seconds: u64,
) -> Self
pub fn new( max_per_minute: usize, max_concurrent: usize, backoff_seconds: u64, ) -> Self
Create a new rate limiter
Sourcepub fn try_acquire(&self) -> Result<(), u64>
pub fn try_acquire(&self) -> Result<(), u64>
Try to acquire permission to process an event Returns Ok(()) if allowed, Err(backoff_seconds) if rate limited
Sourcepub fn stats(&self) -> RateLimiterStats
pub fn stats(&self) -> RateLimiterStats
Get current stats
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RateLimiter
impl RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin for RateLimiter
impl UnwindSafe for RateLimiter
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