pub struct ThrottleSpec {
pub limit: u64,
pub period: u64,
pub max_burst: Option<u64>,
pub force_local: bool,
}
Fields§
§limit: u64
§period: u64
Period, in seconds
max_burst: Option<u64>
Constrain how quickly the throttle can be consumed per throttle interval (period / limit). max_burst defaults to limit, allowing the entire throttle to be used in an instant. Setting max_burst to 1 will only allow 1 throttle bump per interval, spreading out the utilization of the throttle more evenly over time. Larger values allow more of the throttle to be used per period.
force_local: bool
Implementations§
Source§impl ThrottleSpec
impl ThrottleSpec
pub async fn throttle<S: AsRef<str>>( &self, key: S, ) -> Result<ThrottleResult, Error>
pub async fn throttle_quantity<S: AsRef<str>>( &self, key: S, quantity: u64, ) -> Result<ThrottleResult, Error>
Trait Implementations§
Source§impl Clone for ThrottleSpec
impl Clone for ThrottleSpec
Source§fn clone(&self) -> ThrottleSpec
fn clone(&self) -> ThrottleSpec
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ThrottleSpec
impl Debug for ThrottleSpec
Source§impl<'de> Deserialize<'de> for ThrottleSpec
impl<'de> Deserialize<'de> for ThrottleSpec
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
Source§impl Display for ThrottleSpec
impl Display for ThrottleSpec
Source§impl From<ThrottleSpec> for String
impl From<ThrottleSpec> for String
Source§fn from(spec: ThrottleSpec) -> String
fn from(spec: ThrottleSpec) -> String
Converts to this type from the input type.
Source§impl Hash for ThrottleSpec
impl Hash for ThrottleSpec
Source§impl PartialEq for ThrottleSpec
impl PartialEq for ThrottleSpec
Source§impl Serialize for ThrottleSpec
impl Serialize for ThrottleSpec
Source§impl TryFrom<&str> for ThrottleSpec
impl TryFrom<&str> for ThrottleSpec
Source§impl TryFrom<String> for ThrottleSpec
impl TryFrom<String> for ThrottleSpec
impl Copy for ThrottleSpec
impl Eq for ThrottleSpec
impl StructuralPartialEq for ThrottleSpec
Auto Trait Implementations§
impl Freeze for ThrottleSpec
impl RefUnwindSafe for ThrottleSpec
impl Send for ThrottleSpec
impl Sync for ThrottleSpec
impl Unpin for ThrottleSpec
impl UnwindSafe for ThrottleSpec
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more