pub struct RateLimit {
pub name: Option<String>,
pub algorithm: Option<String>,
pub limit: Option<i64>,
pub window_millis: Option<i64>,
pub burst: Option<i64>,
pub refill_per_second: Option<f64>,
pub error_status: Option<i32>,
pub retry_after: Option<String>,
pub extra: Extra,
}Expand description
Declarative, protocol-agnostic rate limit / quota attached to an expectation.
Fields§
§name: Option<String>§algorithm: Option<String>"fixed_window" (default) or "token_bucket".
limit: Option<i64>§window_millis: Option<i64>§burst: Option<i64>§refill_per_second: Option<f64>§error_status: Option<i32>§retry_after: Option<String>§extra: ExtraImplementations§
Source§impl RateLimit
impl RateLimit
Sourcepub fn fixed_window(limit: i64, window_millis: i64) -> Self
pub fn fixed_window(limit: i64, window_millis: i64) -> Self
Create a fixed_window rate limit of limit requests per window_millis.
Sourcepub fn token_bucket(burst: i64, refill_per_second: f64) -> Self
pub fn token_bucket(burst: i64, refill_per_second: f64) -> Self
Create a token_bucket rate limit with burst capacity refilled at
refill_per_second tokens per second.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RateLimit
impl<'de> Deserialize<'de> for RateLimit
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for RateLimit
Auto Trait Implementations§
impl Freeze for RateLimit
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnsafeUnpin for RateLimit
impl UnwindSafe for RateLimit
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