cloud_hypervisor_client/models/
token_bucket.rs

1/*
2 * Cloud Hypervisor API
3 *
4 * Local HTTP based API for managing and inspecting a cloud-hypervisor virtual machine.
5 *
6 * The version of the OpenAPI document: 0.3.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// 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.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct TokenBucket {
17    /// The total number of tokens this bucket can hold.
18    #[serde(rename = "size")]
19    pub size: i64,
20    /// The initial size of a token bucket.
21    #[serde(rename = "one_time_burst", skip_serializing_if = "Option::is_none")]
22    pub one_time_burst: Option<i64>,
23    /// The amount of milliseconds it takes for the bucket to refill.
24    #[serde(rename = "refill_time")]
25    pub refill_time: i64,
26}
27
28impl TokenBucket {
29    /// 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.
30    pub fn new(size: i64, refill_time: i64) -> TokenBucket {
31        TokenBucket {
32            size,
33            one_time_burst: None,
34            refill_time,
35        }
36    }
37}