CacheAwareRateLimiter

Trait CacheAwareRateLimiter 

Source
pub trait CacheAwareRateLimiter:
    Send
    + Sync
    + 'static {
    // Required methods
    fn until_key_ready<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn check_key(&self, key: &str) -> bool;
}
Available on crate feature rate-limiting only.
Expand description

A trait for rate limiting that can be implemented by different rate limiting strategies

Required Methods§

Source

fn until_key_ready<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Wait until a request to the given key (typically a domain or URL) is allowed This method should block until the rate limit allows the request to proceed

Source

fn check_key(&self, key: &str) -> bool

Check if a request to the given key would be allowed without blocking Returns true if the request can proceed immediately, false if it would be rate limited

Implementors§