pub struct WorkerRateLimiter { /* private fields */ }Expand description
Thread-safe per-worker rate limiter
Wraps a rate limiter for safe concurrent access from multiple worker threads.
Implementations§
Source§impl WorkerRateLimiter
impl WorkerRateLimiter
Sourcepub fn with_default(config: RateLimitConfig) -> Self
pub fn with_default(config: RateLimitConfig) -> Self
Create with a default rate limit
Sourcepub fn set_task_rate(
&self,
task_name: impl Into<String>,
config: RateLimitConfig,
)
pub fn set_task_rate( &self, task_name: impl Into<String>, config: RateLimitConfig, )
Set rate limit for a specific task type
Sourcepub fn remove_task_rate(&self, task_name: &str)
pub fn remove_task_rate(&self, task_name: &str)
Remove rate limit for a specific task type
Sourcepub fn try_acquire(&self, task_name: &str) -> bool
pub fn try_acquire(&self, task_name: &str) -> bool
Try to acquire a permit for a specific task
Sourcepub fn time_until_available(&self, task_name: &str) -> Duration
pub fn time_until_available(&self, task_name: &str) -> Duration
Get time until a task can be executed
Sourcepub fn has_rate_limit(&self, task_name: &str) -> bool
pub fn has_rate_limit(&self, task_name: &str) -> bool
Check if a task type has a rate limit configured
Trait Implementations§
Source§impl Clone for WorkerRateLimiter
impl Clone for WorkerRateLimiter
Source§fn clone(&self) -> WorkerRateLimiter
fn clone(&self) -> WorkerRateLimiter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WorkerRateLimiter
impl Debug for WorkerRateLimiter
Auto Trait Implementations§
impl Freeze for WorkerRateLimiter
impl RefUnwindSafe for WorkerRateLimiter
impl Send for WorkerRateLimiter
impl Sync for WorkerRateLimiter
impl Unpin for WorkerRateLimiter
impl UnwindSafe for WorkerRateLimiter
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