Struct TpsBudget
struct TpsBudget { ... }
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.
-
impl Budget for TpsBudget
fn deposit(self: &Self)fn withdraw(self: &Self) -> bool
impl Debug for TpsBudget
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Default for TpsBudget
fn default() -> Self
impl Freeze for TpsBudget
impl RefUnwindSafe for TpsBudget
impl Send for TpsBudget
impl Sync for TpsBudget
impl Unpin for TpsBudget
impl UnwindSafe for TpsBudget
impl<T> Any for TpsBudget
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for TpsBudget
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for TpsBudget
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for TpsBudget
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for TpsBudget
impl<T> WithSubscriber for TpsBudget
impl<T, U> Into for TpsBudget
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for TpsBudget
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for TpsBudget
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>