pub struct TokenBucket { /* private fields */ }Expand description
Token bucket that bounds retries — a client-side retry quota.
Each retry attempt acquires tokens from the bucket; successful requests return or refill
tokens. When the bucket is empty, the retry strategy stops retrying and returns the error to
the caller, even if max_attempts has not been reached.
A single token bucket is shared by every operation in a RetryPartition. Use
TokenBucket::builder to configure its capacity and
refill_rate, and attach it to a custom RetryPartition
to give a workload its own bucket instead of sharing the default one.
use aws_smithy_runtime::client::retries::TokenBucket;
let token_bucket = TokenBucket::builder()
.capacity(5000)
.refill_rate(100.0) // tokens regenerated per second
.build();A custom RetryPartition carrying this bucket can then be set on a generated client’s config
builder via its retry_partition method.
Implementations§
Source§impl TokenBucket
impl TokenBucket
Sourcepub fn new(initial_quota: usize) -> TokenBucket
pub fn new(initial_quota: usize) -> TokenBucket
Creates a new TokenBucket with the given initial quota.
Sourcepub fn unlimited() -> TokenBucket
pub fn unlimited() -> TokenBucket
A token bucket with unlimited capacity that allows retries at no cost.
Sourcepub fn builder() -> TokenBucketBuilder
pub fn builder() -> TokenBucketBuilder
Creates a builder for constructing a TokenBucket.
Trait Implementations§
Source§impl Clone for TokenBucket
impl Clone for TokenBucket
Source§fn clone(&self) -> TokenBucket
fn clone(&self) -> TokenBucket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TokenBucket
impl Debug for TokenBucket
Source§impl Default for TokenBucket
impl Default for TokenBucket
Source§fn default() -> TokenBucket
fn default() -> TokenBucket
Source§impl Storable for TokenBucket
impl Storable for TokenBucket
Source§type Storer = StoreReplace<TokenBucket>
type Storer = StoreReplace<TokenBucket>
StoreReplace and StoreAppendAuto Trait Implementations§
impl !RefUnwindSafe for TokenBucket
impl !UnwindSafe for TokenBucket
impl Freeze for TokenBucket
impl Send for TokenBucket
impl Sync for TokenBucket
impl Unpin for TokenBucket
impl UnsafeUnpin for TokenBucket
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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