Skip to content

Commit be2e9b1

Browse files
committed
feat: improve config handling
1 parent 21723fd commit be2e9b1

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
members = ["object-store"]
33

44
[patch.crates-io]
5-
object_store = { git = "https://github.com/roeap/arrow-rs", rev = "3ab6ac8ab66ca5387c8265eacb00279253004bb9" }
5+
object_store = { git = "https://github.com/roeap/arrow-rs", rev = "7dea6c8ee68dbda781ee613e537f2a65891ed322" }

object-store/src/builder.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ impl ObjectStoreBuilder {
9999
}
100100
}
101101

102-
pub fn with_options(mut self, options: HashMap<String, String>) -> Self {
103-
self.options = options;
102+
pub fn with_options<I: IntoIterator<Item = (impl Into<String>, impl Into<String>)>>(
103+
mut self,
104+
options: I,
105+
) -> Self {
106+
self.options
107+
.extend(options.into_iter().map(|(k, v)| (k.into(), v.into())));
104108
self
105109
}
106110

@@ -158,7 +162,7 @@ impl ObjectStoreBuilder {
158162
ObjectStoreKind::Azure => {
159163
let maybe_store = MicrosoftAzureBuilder::new()
160164
.with_url(url.clone())
161-
.with_options(&self.options)
165+
.try_with_options(&self.options)?
162166
.with_client_options(self.client_options.clone().unwrap_or_default())
163167
.with_retry(self.retry_config.clone().unwrap_or_default())
164168
.build();
@@ -167,7 +171,7 @@ impl ObjectStoreBuilder {
167171
} else {
168172
let store = MicrosoftAzureBuilder::from_env()
169173
.with_url(url.clone())
170-
.with_options(&self.options)
174+
.try_with_options(&self.options)?
171175
.with_client_options(self.client_options.unwrap_or_default())
172176
.with_retry(self.retry_config.unwrap_or_default())
173177
.build()?;
@@ -177,7 +181,7 @@ impl ObjectStoreBuilder {
177181
ObjectStoreKind::S3 => {
178182
let maybe_store = AmazonS3Builder::new()
179183
.with_url(url.clone())
180-
.with_options(&self.options)
184+
.try_with_options(&self.options)?
181185
.with_client_options(self.client_options.clone().unwrap_or_default())
182186
.with_retry(self.retry_config.clone().unwrap_or_default())
183187
.build();
@@ -186,7 +190,7 @@ impl ObjectStoreBuilder {
186190
} else {
187191
let store = AmazonS3Builder::from_env()
188192
.with_url(url.clone())
189-
.with_options(&self.options)
193+
.try_with_options(&self.options)?
190194
.with_client_options(self.client_options.unwrap_or_default())
191195
.with_retry(self.retry_config.unwrap_or_default())
192196
.build()?;
@@ -196,7 +200,7 @@ impl ObjectStoreBuilder {
196200
ObjectStoreKind::Google => {
197201
let maybe_store = GoogleCloudStorageBuilder::new()
198202
.with_url(url.clone())
199-
.with_options(&self.options)
203+
.try_with_options(&self.options)?
200204
.with_client_options(self.client_options.clone().unwrap_or_default())
201205
.with_retry(self.retry_config.clone().unwrap_or_default())
202206
.build();
@@ -205,7 +209,7 @@ impl ObjectStoreBuilder {
205209
} else {
206210
let store = GoogleCloudStorageBuilder::from_env()
207211
.with_url(url.clone())
208-
.with_options(&self.options)
212+
.try_with_options(&self.options)?
209213
.with_client_options(self.client_options.unwrap_or_default())
210214
.with_retry(self.retry_config.unwrap_or_default())
211215
.build()?;

0 commit comments

Comments
 (0)