Struct relay_quotas::CachedRateLimits
source · pub struct CachedRateLimits(/* private fields */);
Expand description
Like RateLimits
, a collection of scoped rate limits but with all the checks
necessary to cache the limits.
The data structure makes sure no expired rate limits are enforced as well as removing any indexed rate limit.
Cached rate limits don’t enforce indexed rate limits because at the time of the check the decision whether an envelope is sampled or not is not yet known. Additionally even if the item is later dropped by dynamic sampling, it must still be around to extract metrics and cannot be dropped too early.
Implementations§
source§impl CachedRateLimits
impl CachedRateLimits
sourcepub fn add(&mut self, limit: RateLimit)
pub fn add(&mut self, limit: RateLimit)
Adds a limit to this collection.
See also: RateLimits::add
.
sourcepub fn merge(&mut self, rate_limits: RateLimits)
pub fn merge(&mut self, rate_limits: RateLimits)
Merges more rate limits into this instance.
See also: RateLimits::merge
.
sourcepub fn current_limits(&mut self) -> &RateLimits
pub fn current_limits(&mut self) -> &RateLimits
Returns a reference to the contained rate limits.
This call gurantuess that at the time of call no returned rate limit is expired.