pub struct CachedCredentialsProvider { /* private fields */ }Expand description
Expiration-aware provider that coalesces concurrent refresh requests.
A refresh is performed while holding a Tokio mutex. Concurrent callers wait for that single refresh and then consume the same cached result, preventing refresh storms. If an early refresh fails, credentials that have not actually expired are returned until a later call can retry.
Implementations§
Source§impl CachedCredentialsProvider
impl CachedCredentialsProvider
Sourcepub fn new(provider: Arc<dyn CredentialsProvider>) -> Self
pub fn new(provider: Arc<dyn CredentialsProvider>) -> Self
Wraps a provider and refreshes expiring credentials one minute early.
Sourcepub fn with_refresh_before(
provider: Arc<dyn CredentialsProvider>,
refresh_before: Duration,
) -> Self
pub fn with_refresh_before( provider: Arc<dyn CredentialsProvider>, refresh_before: Duration, ) -> Self
Wraps a provider with a custom early-refresh window.
Sourcepub async fn invalidate(&self)
pub async fn invalidate(&self)
Clears the current cache entry so the next request refreshes it.
Trait Implementations§
Source§impl CredentialsProvider for CachedCredentialsProvider
impl CredentialsProvider for CachedCredentialsProvider
Source§fn provide_credentials<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credentials, S3Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn provide_credentials<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credentials, S3Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resolves credentials for a request.
Auto Trait Implementations§
impl !Freeze for CachedCredentialsProvider
impl !RefUnwindSafe for CachedCredentialsProvider
impl !UnwindSafe for CachedCredentialsProvider
impl Send for CachedCredentialsProvider
impl Sync for CachedCredentialsProvider
impl Unpin for CachedCredentialsProvider
impl UnsafeUnpin for CachedCredentialsProvider
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.