Skip to content

Commit

Permalink
feat: improve config handling
Browse files Browse the repository at this point in the history
  • Loading branch information
roeap committed Jan 4, 2023
1 parent 21723fd commit be2e9b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
members = ["object-store"]

[patch.crates-io]
object_store = { git = "https://github.com/roeap/arrow-rs", rev = "3ab6ac8ab66ca5387c8265eacb00279253004bb9" }
object_store = { git = "https://github.com/roeap/arrow-rs", rev = "7dea6c8ee68dbda781ee613e537f2a65891ed322" }
20 changes: 12 additions & 8 deletions object-store/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ impl ObjectStoreBuilder {
}
}

pub fn with_options(mut self, options: HashMap<String, String>) -> Self {
self.options = options;
pub fn with_options<I: IntoIterator<Item = (impl Into<String>, impl Into<String>)>>(
mut self,
options: I,
) -> Self {
self.options
.extend(options.into_iter().map(|(k, v)| (k.into(), v.into())));
self
}

Expand Down Expand Up @@ -158,7 +162,7 @@ impl ObjectStoreBuilder {
ObjectStoreKind::Azure => {
let maybe_store = MicrosoftAzureBuilder::new()
.with_url(url.clone())
.with_options(&self.options)
.try_with_options(&self.options)?
.with_client_options(self.client_options.clone().unwrap_or_default())
.with_retry(self.retry_config.clone().unwrap_or_default())
.build();
Expand All @@ -167,7 +171,7 @@ impl ObjectStoreBuilder {
} else {
let store = MicrosoftAzureBuilder::from_env()
.with_url(url.clone())
.with_options(&self.options)
.try_with_options(&self.options)?
.with_client_options(self.client_options.unwrap_or_default())
.with_retry(self.retry_config.unwrap_or_default())
.build()?;
Expand All @@ -177,7 +181,7 @@ impl ObjectStoreBuilder {
ObjectStoreKind::S3 => {
let maybe_store = AmazonS3Builder::new()
.with_url(url.clone())
.with_options(&self.options)
.try_with_options(&self.options)?
.with_client_options(self.client_options.clone().unwrap_or_default())
.with_retry(self.retry_config.clone().unwrap_or_default())
.build();
Expand All @@ -186,7 +190,7 @@ impl ObjectStoreBuilder {
} else {
let store = AmazonS3Builder::from_env()
.with_url(url.clone())
.with_options(&self.options)
.try_with_options(&self.options)?
.with_client_options(self.client_options.unwrap_or_default())
.with_retry(self.retry_config.unwrap_or_default())
.build()?;
Expand All @@ -196,7 +200,7 @@ impl ObjectStoreBuilder {
ObjectStoreKind::Google => {
let maybe_store = GoogleCloudStorageBuilder::new()
.with_url(url.clone())
.with_options(&self.options)
.try_with_options(&self.options)?
.with_client_options(self.client_options.clone().unwrap_or_default())
.with_retry(self.retry_config.clone().unwrap_or_default())
.build();
Expand All @@ -205,7 +209,7 @@ impl ObjectStoreBuilder {
} else {
let store = GoogleCloudStorageBuilder::from_env()
.with_url(url.clone())
.with_options(&self.options)
.try_with_options(&self.options)?
.with_client_options(self.client_options.unwrap_or_default())
.with_retry(self.retry_config.unwrap_or_default())
.build()?;
Expand Down

0 comments on commit be2e9b1

Please sign in to comment.