Struct aws_credential_types::lazy_caching::Builder
source · pub struct Builder { /* private fields */ }
Expand description
Builder for constructing a LazyCachingCredentialsProvider
.
Examples
use aws_credential_types::Credentials;
use aws_credential_types::credential_fn::provide_credentials_fn;
use aws_credential_types::lazy_caching::LazyCachingCredentialsProvider;
let provider = LazyCachingCredentialsProvider::builder()
.load(provide_credentials_fn(|| async {
// An async process to retrieve credentials would go here:
Ok(Credentials::new("example", "example", None, None, "my_provider_name"))
}))
.build();
Implementations§
source§impl Builder
impl Builder
sourcepub fn configure(
self,
sleep: Option<Arc<dyn AsyncSleep>>,
time_source: TimeSource
) -> Self
pub fn configure( self, sleep: Option<Arc<dyn AsyncSleep>>, time_source: TimeSource ) -> Self
Override configuration for the Builder
sourcepub fn load(self, loader: impl ProvideCredentials + 'static) -> Self
pub fn load(self, loader: impl ProvideCredentials + 'static) -> Self
An implementation of ProvideCredentials
that will be used to load
the cached credentials once they’re expired.
sourcepub fn set_load(
&mut self,
loader: Option<impl ProvideCredentials + 'static>
) -> &mut Self
pub fn set_load( &mut self, loader: Option<impl ProvideCredentials + 'static> ) -> &mut Self
An implementation of ProvideCredentials
that will be used to load
the cached credentials once they’re expired.
sourcepub fn sleep(self, sleep: impl AsyncSleep + 'static) -> Self
pub fn sleep(self, sleep: impl AsyncSleep + 'static) -> Self
Implementation of AsyncSleep
to use for timeouts.
This enables use of the LazyCachingCredentialsProvider
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<impl AsyncSleep + 'static>
) -> &mut Self
pub fn set_sleep( &mut self, sleep: Option<impl AsyncSleep + 'static> ) -> &mut Self
Implementation of AsyncSleep
to use for timeouts.
This enables use of the LazyCachingCredentialsProvider
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 build(self) -> LazyCachingCredentialsProvider
pub fn build(self) -> LazyCachingCredentialsProvider
Creates the LazyCachingCredentialsProvider
.
Panics
This will panic if no sleep
implementation is given and if no default crate features
are used. By default, the TokioSleep
implementation will be set automatically.