pub struct TaskRateLimiter { /* private fields */ }Expand description
Per-task rate limiter manager
Manages rate limiters for multiple task types, allowing different rate limits per task name.
Implementations§
Source§impl TaskRateLimiter
impl TaskRateLimiter
Sourcepub fn with_default(config: RateLimitConfig) -> Self
pub fn with_default(config: RateLimitConfig) -> Self
Create with a default rate limit for all tasks
Sourcepub fn set_task_rate(
&mut self,
task_name: impl Into<String>,
config: RateLimitConfig,
)
pub fn set_task_rate( &mut self, task_name: impl Into<String>, config: RateLimitConfig, )
Set rate limit for a specific task type
Sourcepub fn remove_task_rate(&mut self, task_name: &str)
pub fn remove_task_rate(&mut self, task_name: &str)
Remove rate limit for a specific task type
Sourcepub fn try_acquire(&mut self, task_name: &str) -> bool
pub fn try_acquire(&mut self, task_name: &str) -> bool
Try to acquire a permit for a specific task
Returns true if the task can execute, false if rate limited
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
Sourcepub fn get_rate_limit(&self, task_name: &str) -> Option<&RateLimitConfig>
pub fn get_rate_limit(&self, task_name: &str) -> Option<&RateLimitConfig>
Get the rate limit configuration for a task
Trait Implementations§
Source§impl Debug for TaskRateLimiter
impl Debug for TaskRateLimiter
Auto Trait Implementations§
impl Freeze for TaskRateLimiter
impl RefUnwindSafe for TaskRateLimiter
impl Send for TaskRateLimiter
impl Sync for TaskRateLimiter
impl Unpin for TaskRateLimiter
impl UnwindSafe for TaskRateLimiter
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