Struct TpsBudget
pub struct TpsBudget { /* private fields */ }
A Transactions Per Minute config for managing retry tokens.
TpsBudget uses a token bucket to decide if the request should be retried.
TpsBudget works by checking how much retries have been made in a certain period of time.
Minimum allowed number of retries are effectively reset on an interval. Allowed number of
retries depends on failed request count in recent time frame.
For more info about Budget, please see the module-level documentation.
Implementations
impl TpsBudget
fn new(ttl: Duration, min_per_sec: u32, retry_percent: f32) -> SelfCreate a
TpsBudgetthat allows for a certain percent of the total requests to be retried.-
The
ttlis the duration of how long a singledepositshould be considered. Must be between 1 and 60 seconds. -
The
min_per_secis the minimum rate of retries allowed to accommodate clients that have just started issuing requests, or clients that do not issue many requests per window. -
The
retry_percentis the percentage of calls todepositthat can be retried. This is in addition to any retries allowed for viamin_per_sec. Must be between 0 and 1000.As an example, if
0.1is used, then for every 10 calls todeposit, 1 retry will be allowed. If2.0is used, then everydepositallows for 2 retries.
-
Trait Implementations
impl Budget for TpsBudget
fn deposit(&self)fn withdraw(&self) -> bool
impl Debug for TpsBudget
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for TpsBudget
fn default() -> Self
Auto Trait Implementations
impl !Freeze for TpsBudget
impl RefUnwindSafe for TpsBudget
impl Send for TpsBudget
impl Sync for TpsBudget
impl Unpin for TpsBudget
impl UnsafeUnpin for TpsBudget
impl UnwindSafe for TpsBudget
Blanket Implementations
impl<T> Any for TpsBudget
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for TpsBudget
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for TpsBudget
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for TpsBudget
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for TpsBudget
impl<T> WithSubscriber for TpsBudget
impl<T, U> Into<U> for TpsBudget
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for TpsBudget
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for TpsBudget
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>