CachedCredentialsProvider

class CachedCredentialsProvider(source: CredentialsProvider, expireCredentialsAfter: <Error class: unknown class> = DEFAULT_CREDENTIALS_REFRESH_SECONDS.seconds, refreshBufferWindow: <Error class: unknown class> = DEFAULT_CREDENTIALS_REFRESH_BUFFER_SECONDS.seconds, clock: <Error class: unknown class> = Clock.System) : CloseableCredentialsProvider

Creates a provider that functions as a caching decorator of another provider.

Credentials sourced through this provider will be cached within it until their expiration time. When the cached credentials expire, new credentials will be fetched when next queried.

For example, the default chain is implemented as:

CachedProvider -> ProviderChain(EnvironmentProvider -> ProfileProvider -> ECS/EC2IMD etc...)

Return

the newly-constructed credentials provider

Parameters

source

the provider to cache credentials results from

expireCredentialsAfter

the default expiration time period for sourced credentials. For a given set of cached credentials, the refresh time period will be the minimum of this time and any expiration timestamp on the credentials themselves.

refreshBufferWindow

amount of time before the actual credential expiration time when credentials are considered expired. For example, if credentials are expiring in 15 minutes, and the buffer time is 10 seconds, then any requests made after 14 minutes and 50 seconds will load new credentials. Defaults to 10 seconds.

clock

the source of time for this provider

Constructors

Link copied to clipboard
constructor(source: CredentialsProvider, expireCredentialsAfter: <Error class: unknown class> = DEFAULT_CREDENTIALS_REFRESH_SECONDS.seconds, refreshBufferWindow: <Error class: unknown class> = DEFAULT_CREDENTIALS_REFRESH_BUFFER_SECONDS.seconds, clock: <Error class: unknown class> = Clock.System)

Inherited properties

Link copied to clipboard

Retrieves the simple name of the class implementing CredentialsProvider.

Functions

Link copied to clipboard
open fun close()
Link copied to clipboard
open suspend override fun resolve(attributes: <Error class: unknown class>): Credentials

Request credentials from the provider

Link copied to clipboard
open override fun toString(): String

Inherited functions

Link copied to clipboard
fun CredentialsProvider.cached(expireCredentialsAfter: <Error class: unknown class> = DEFAULT_CREDENTIALS_REFRESH_SECONDS.seconds, refreshBufferWindow: <Error class: unknown class> = DEFAULT_CREDENTIALS_REFRESH_BUFFER_SECONDS.seconds, clock: <Error class: unknown class> = Clock.System): CachedCredentialsProvider

A utility function which wraps a CredentialsProvider in a CachedCredentialsProvider.