pub struct Builder { /* private fields */ }
Implementations§
source§impl Builder
impl Builder
sourcepub fn max_tokens(self, tokens: u64) -> Self
pub fn max_tokens(self, tokens: u64) -> Self
Set the max tokens that can be held in the the Ratelimiter
at any
time. This limits the size of any bursts by placing an upper bound on
the number of tokens available for immediate use.
By default, the max_tokens will be set to one unless the refill amount requires a higher value.
The selected value cannot be lower than the refill amount.
sourcepub fn initial_available(self, tokens: u64) -> Self
pub fn initial_available(self, tokens: u64) -> Self
Set the number of tokens that are initially available. For admission control scenarios, you may wish for there to be some tokens initially available to avoid delays or discards until the ratelimit is hit. When using it to enforce a ratelimit on your own process, for example when generating outbound requests, you may want there to be zero tokens availble initially to make your application more well-behaved in event of process restarts.
The default is that no tokens are initially available.
sourcepub fn build(self) -> Result<Ratelimiter, Error>
pub fn build(self) -> Result<Ratelimiter, Error>
Consumes this Builder
and attempts to construct a Ratelimiter
.