pub struct TokenBucket {
pub size: i64,
pub one_time_burst: Option<i64>,
pub refill_time: i64,
}Expand description
TokenBucket : Defines a token bucket with a maximum capacity (size), an initial burst size (one_time_burst) and an interval for refilling purposes (refill_time). The refill-rate is derived from size and refill_time, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate.
Fields§
§size: i64The total number of tokens this bucket can hold.
one_time_burst: Option<i64>The initial size of a token bucket.
refill_time: i64The amount of milliseconds it takes for the bucket to refill.
Implementations§
Source§impl TokenBucket
impl TokenBucket
Sourcepub fn new(size: i64, refill_time: i64) -> TokenBucket
pub fn new(size: i64, refill_time: i64) -> TokenBucket
Defines a token bucket with a maximum capacity (size), an initial burst size (one_time_burst) and an interval for refilling purposes (refill_time). The refill-rate is derived from size and refill_time, and it is the constant rate at which the tokens replenish. The refill process only starts happening after the initial burst budget is consumed. Consumption from the token bucket is unbounded in speed which allows for bursts bound in size by the amount of tokens available. Once the token bucket is empty, consumption speed is bound by the refill-rate.
Trait Implementations§
Source§impl Clone for TokenBucket
impl Clone for TokenBucket
Source§fn clone(&self) -> TokenBucket
fn clone(&self) -> TokenBucket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more