Struct aws_credential_types::cache::LazyBuilder
source · pub struct LazyBuilder { /* private fields */ }
Expand description
Builder for constructing a LazyCredentialsCache
.
LazyCredentialsCache
implements ProvideCachedCredentials
by caching
credentials that it loads by calling a user-provided ProvideCredentials
implementation.
For example, you can provide a ProvideCredentials
implementation that calls
AWS STS’s AssumeRole operation to get temporary credentials, and LazyCredentialsCache
will cache those credentials until they expire.
Callers outside of this crate cannot call build
directly. They can instead call
into_credentials_cache
to obtain a CredentialsCache
. Its create_cache
then calls
build
to create a LazyCredentialsCache
.
Implementations§
source§impl Builder
impl Builder
sourcepub fn sleep(self, sleep: Arc<dyn AsyncSleep>) -> Self
pub fn sleep(self, sleep: Arc<dyn AsyncSleep>) -> Self
Implementation of AsyncSleep
to use for timeouts.
This enables use of the LazyCredentialsCache
with other async runtimes.
If using Tokio as the async runtime, this should be set to an instance of
TokioSleep
.
sourcepub fn set_sleep(&mut self, sleep: Option<Arc<dyn AsyncSleep>>) -> &mut Self
pub fn set_sleep(&mut self, sleep: Option<Arc<dyn AsyncSleep>>) -> &mut Self
Implementation of AsyncSleep
to use for timeouts.
This enables use of the LazyCredentialsCache
with other async runtimes.
If using Tokio as the async runtime, this should be set to an instance of
TokioSleep
.
sourcepub fn load_timeout(self, timeout: Duration) -> Self
pub fn load_timeout(self, timeout: Duration) -> Self
Timeout for the given ProvideCredentials
implementation.
Defaults to 5 seconds.
sourcepub fn set_load_timeout(&mut self, timeout: Option<Duration>) -> &mut Self
pub fn set_load_timeout(&mut self, timeout: Option<Duration>) -> &mut Self
Timeout for the given ProvideCredentials
implementation.
Defaults to 5 seconds.
sourcepub fn buffer_time(self, buffer_time: Duration) -> Self
pub fn buffer_time(self, buffer_time: Duration) -> Self
Amount of time before the actual credential expiration time where 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.
sourcepub fn set_buffer_time(&mut self, buffer_time: Option<Duration>) -> &mut Self
pub fn set_buffer_time(&mut self, buffer_time: Option<Duration>) -> &mut Self
Amount of time before the actual credential expiration time where 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.
sourcepub fn default_credential_expiration(self, duration: Duration) -> Self
pub fn default_credential_expiration(self, duration: Duration) -> Self
Default expiration time to set on credentials if they don’t have an expiration time.
This is only used if the given ProvideCredentials
returns
Credentials
that don’t have their expiry
set.
This must be at least 15 minutes.
Defaults to 15 minutes.
sourcepub fn set_default_credential_expiration(
&mut self,
duration: Option<Duration>
) -> &mut Self
pub fn set_default_credential_expiration( &mut self, duration: Option<Duration> ) -> &mut Self
Default expiration time to set on credentials if they don’t have an expiration time.
This is only used if the given ProvideCredentials
returns
Credentials
that don’t have their expiry
set.
This must be at least 15 minutes.
Defaults to 15 minutes.
sourcepub fn into_credentials_cache(self) -> CredentialsCache
pub fn into_credentials_cache(self) -> CredentialsCache
Converts Builder
into CredentialsCache
.