aws_smithy_runtime/client/
retries.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6/// Smithy retry classifiers.
7pub mod classifiers;
8
9/// Smithy retry strategies.
10pub mod strategy;
11
12mod client_rate_limiter;
13mod token_bucket;
14
15use aws_smithy_types::config_bag::{Storable, StoreReplace};
16use std::fmt;
17
18pub use client_rate_limiter::ClientRateLimiter;
19pub use token_bucket::TokenBucket;
20
21pub use client_rate_limiter::ClientRateLimiterPartition;
22use std::borrow::Cow;
23
24/// Represents the retry partition, e.g. an endpoint, a region
25#[non_exhaustive]
26#[derive(Clone, Debug, Hash, PartialEq, Eq)]
27pub struct RetryPartition {
28    name: Cow<'static, str>,
29}
30
31impl RetryPartition {
32    /// Creates a new `RetryPartition` from the given `name`.
33    pub fn new(name: impl Into<Cow<'static, str>>) -> Self {
34        Self { name: name.into() }
35    }
36}
37
38impl fmt::Display for RetryPartition {
39    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40        f.write_str(&self.name)
41    }
42}
43
44impl Storable for RetryPartition {
45    type Storer = StoreReplace<RetryPartition>;
46}