pub struct DomainRateLimiter { /* private fields */ }
Available on crate feature
rate-limiting
only.Expand description
A domain-based rate limiter using governor that limits requests per domain
Implementations§
Source§impl DomainRateLimiter
impl DomainRateLimiter
Sourcepub fn new(quota: Quota) -> DomainRateLimiter
pub fn new(quota: Quota) -> DomainRateLimiter
Create a new domain-based rate limiter with the given quota
§Example
ⓘ
use http_cache::rate_limiting::{DomainRateLimiter, Quota};
use std::time::Duration;
use std::num::NonZero;
// Allow 10 requests per minute per domain
let quota = Quota::per_minute(NonZero::new(10).unwrap());
let limiter = DomainRateLimiter::new(quota);
Trait Implementations§
Source§impl CacheAwareRateLimiter for DomainRateLimiter
impl CacheAwareRateLimiter for DomainRateLimiter
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,
DomainRateLimiter: 'async_trait,
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,
DomainRateLimiter: '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
Auto Trait Implementations§
impl Freeze for DomainRateLimiter
impl !RefUnwindSafe for DomainRateLimiter
impl Send for DomainRateLimiter
impl Sync for DomainRateLimiter
impl Unpin for DomainRateLimiter
impl UnwindSafe for DomainRateLimiter
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more