Skip to content

Commit

Permalink
fix: improve ability to control dynamo creds cache
Browse files Browse the repository at this point in the history
  • Loading branch information
albertlockett committed Jan 26, 2024
1 parent 771fe5f commit f7c67ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions rust/lance-io/src/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const AWS_CREDS_CACHE_KEY: &str = "aws_credentials";

/// Adapt an AWS SDK cred into object_store credentials
#[derive(Debug)]
struct AwsCredentialAdapter {
pub struct AwsCredentialAdapter {
pub inner: Arc<dyn ProvideCredentials>,

// RefCell can't be shared accross threads, so we use HashMap
Expand All @@ -119,7 +119,10 @@ struct AwsCredentialAdapter {
}

impl AwsCredentialAdapter {
fn new(provider: Arc<dyn ProvideCredentials>, credentials_refresh_offset: Duration) -> Self {
pub fn new(
provider: Arc<dyn ProvideCredentials>,
credentials_refresh_offset: Duration,
) -> Self {
Self {
inner: provider,
cache: Arc::new(RwLock::new(HashMap::new())),
Expand Down
6 changes: 5 additions & 1 deletion rust/lance-table/src/io/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ use lance_io::object_store::ObjectStoreParams;
#[cfg(feature = "dynamodb")]
use {
self::external_manifest::{ExternalManifestCommitHandler, ExternalManifestStore},
aws_credential_types::cache::CredentialsCache,
lance_io::object_store::{build_aws_credential, StorageOptions},
object_store::aws::AmazonS3ConfigKey,
std::borrow::Cow,
Expand Down Expand Up @@ -295,7 +296,10 @@ async fn build_dynamodb_external_store(

let dynamodb_config = aws_sdk_dynamodb::config::Builder::new()
.region(Some(Region::new(region.to_string())))
.credentials_provider(OSObjectStoreToAwsCredAdaptor(creds));
.credentials_provider(OSObjectStoreToAwsCredAdaptor(creds))
// caching should be handled by passed AwsCredentialProvider
.credentials_cache(CredentialsCache::no_caching());

let dynamodb_config = match env::var("DYNAMODB_ENDPOINT") {
Ok(endpoint) => dynamodb_config.endpoint_url(endpoint),
_ => dynamodb_config,
Expand Down

0 comments on commit f7c67ae

Please sign in to comment.