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) -> Self

Create a TpsBudget that allows for a certain percent of the total requests to be retried.

  • The ttl is the duration of how long a single deposit should be considered. Must be between 1 and 60 seconds.

  • The min_per_sec is 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_percent is the percentage of calls to deposit that can be retried. This is in addition to any retries allowed for via min_per_sec. Must be between 0 and 1000.

    As an example, if 0.1 is used, then for every 10 calls to deposit, 1 retry will be allowed. If 2.0 is used, then every deposit allows 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) -> T

Returns the argument unchanged.

impl<T> Instrument for TpsBudget

impl<T> WithSubscriber for TpsBudget

impl<T, U> Into for TpsBudget

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>