Skip to content

Commit bb04455

Browse files
committed
refactor: use upstream config api
1 parent 75581f8 commit bb04455

File tree

8 files changed

+58
-618
lines changed

8 files changed

+58
-618
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
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/apache/arrow-rs", rev = "1889e33da31218ee2c58ad874036b17b699538b9" }
5+
object_store = { git = "https://github.com/roeap/arrow-rs", rev = "3ab6ac8ab66ca5387c8265eacb00279253004bb9" }

object-store/src/builder.rs

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::collections::HashMap;
22
use std::sync::Arc;
33

4-
use object_store::aws::AmazonS3;
5-
use object_store::azure::MicrosoftAzure;
6-
use object_store::gcp::GoogleCloudStorage;
4+
use object_store::aws::{AmazonS3, AmazonS3Builder};
5+
use object_store::azure::{MicrosoftAzure, MicrosoftAzureBuilder};
6+
use object_store::gcp::{GoogleCloudStorage, GoogleCloudStorageBuilder};
77
use object_store::local::LocalFileSystem;
88
use object_store::memory::InMemory;
99
use object_store::path::Path;
@@ -14,8 +14,6 @@ use object_store::{
1414
};
1515
use url::Url;
1616

17-
use crate::config::{aws::S3Config, azure::AzureConfig, google::GoogleConfig};
18-
1917
enum ObjectStoreKind {
2018
Local,
2119
InMemory,
@@ -136,26 +134,65 @@ impl ObjectStoreBuilder {
136134
store: "Generic",
137135
source: Box::new(err),
138136
})?;
139-
let root_store = match ObjectStoreKind::parse_url(&url).unwrap() {
137+
let root_store = match ObjectStoreKind::parse_url(&url)? {
140138
ObjectStoreKind::Local => ObjectStoreImpl::Local(LocalFileSystem::new()),
141139
ObjectStoreKind::InMemory => ObjectStoreImpl::InMemory(InMemory::new()),
142140
ObjectStoreKind::Azure => {
143-
let builder = AzureConfig::get_builder(&self.url, &self.options)?
144-
.with_client_options(self.client_options.unwrap_or_default())
145-
.with_retry(self.retry_config.unwrap_or_default());
146-
ObjectStoreImpl::Azrue(builder.build()?)
141+
let maybe_store = MicrosoftAzureBuilder::new()
142+
.with_url(url.clone())
143+
.with_options(&self.options)
144+
.with_client_options(self.client_options.clone().unwrap_or_default())
145+
.with_retry(self.retry_config.clone().unwrap_or_default())
146+
.build();
147+
if let Ok(store) = maybe_store {
148+
ObjectStoreImpl::Azrue(store)
149+
} else {
150+
let store = MicrosoftAzureBuilder::from_env()
151+
.with_url(url.clone())
152+
.with_options(&self.options)
153+
.with_client_options(self.client_options.unwrap_or_default())
154+
.with_retry(self.retry_config.unwrap_or_default())
155+
.build()?;
156+
ObjectStoreImpl::Azrue(store)
157+
}
147158
}
148159
ObjectStoreKind::S3 => {
149-
let builder = S3Config::get_builder(&self.url, &self.options)?
150-
.with_client_options(self.client_options.unwrap_or_default())
151-
.with_retry(self.retry_config.unwrap_or_default());
152-
ObjectStoreImpl::S3(builder.build()?)
160+
let maybe_store = AmazonS3Builder::new()
161+
.with_url(url.clone())
162+
.with_options(&self.options)
163+
.with_client_options(self.client_options.clone().unwrap_or_default())
164+
.with_retry(self.retry_config.clone().unwrap_or_default())
165+
.build();
166+
if let Ok(store) = maybe_store {
167+
ObjectStoreImpl::S3(store)
168+
} else {
169+
let store = AmazonS3Builder::from_env()
170+
.with_url(url.clone())
171+
.with_options(&self.options)
172+
.with_client_options(self.client_options.unwrap_or_default())
173+
.with_retry(self.retry_config.unwrap_or_default())
174+
.build()?;
175+
ObjectStoreImpl::S3(store)
176+
}
153177
}
154178
ObjectStoreKind::Google => {
155-
let builder = GoogleConfig::get_builder(&self.url, &self.options)?
156-
.with_client_options(self.client_options.unwrap_or_default())
157-
.with_retry(self.retry_config.unwrap_or_default());
158-
ObjectStoreImpl::Gcp(builder.build()?)
179+
let maybe_store = GoogleCloudStorageBuilder::new()
180+
.with_url(url.clone())
181+
.with_options(&self.options)
182+
.with_client_options(self.client_options.clone().unwrap_or_default())
183+
.with_retry(self.retry_config.clone().unwrap_or_default())
184+
.build();
185+
if let Ok(store) = maybe_store {
186+
ObjectStoreImpl::Gcp(store)
187+
} else {
188+
let store = GoogleCloudStorageBuilder::from_env()
189+
.with_url(url.clone())
190+
.with_options(&self.options)
191+
.with_client_options(self.client_options.unwrap_or_default())
192+
.with_retry(self.retry_config.unwrap_or_default())
193+
.build()?;
194+
ObjectStoreImpl::Gcp(store)
195+
}
159196
}
160197
};
161198

object-store/src/config/aws.rs

Lines changed: 0 additions & 237 deletions
This file was deleted.

0 commit comments

Comments
 (0)