pub struct CachedCredentialProvider<P> { /* private fields */ }Expand description
TTL cache wrapping any inner CredentialProvider. Resolves
once, hands back the cached value until ttl elapses, then
refreshes by calling the inner provider exactly once even under
concurrent load (concurrent waiters share the in-flight refresh
future).
The wrapper is the recommended baseline for production credential chains: short-lived bearer tokens (OAuth, AWS STS, Azure AAD) all expose a TTL, and refusing to cache hammers the credential source once per request.
On refresh failure the cache surfaces the inner error and does not poison the slot — a subsequent call retries. This keeps transient credential-source outages from cascading into permanent agent failure.
Implementations§
Source§impl<P> CachedCredentialProvider<P>where
P: CredentialProvider,
impl<P> CachedCredentialProvider<P>where
P: CredentialProvider,
Trait Implementations§
Source§impl<P> CredentialProvider for CachedCredentialProvider<P>where
P: CredentialProvider,
impl<P> CredentialProvider for CachedCredentialProvider<P>where
P: CredentialProvider,
Source§fn resolve<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resolve<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resolve current credentials. Long-running impls should respect
tokio cancellation in their internals; the transport supplies the
ExecutionContext indirectly via the surrounding async task.Auto Trait Implementations§
impl<P> !Freeze for CachedCredentialProvider<P>
impl<P> !RefUnwindSafe for CachedCredentialProvider<P>
impl<P> Send for CachedCredentialProvider<P>
impl<P> Sync for CachedCredentialProvider<P>
impl<P> Unpin for CachedCredentialProvider<P>
impl<P> UnsafeUnpin for CachedCredentialProvider<P>
impl<P> UnwindSafe for CachedCredentialProvider<P>where
P: RefUnwindSafe,
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