-
Notifications
You must be signed in to change notification settings - Fork 68
Initial HTTP support for Virtual Refs #938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fc417f0
1b0ee62
64e2648
c1a4c21
13e10cb
6892862
86c5d23
be2c5e8
0ceff6b
d50d2df
66fca0a
a45b276
243739f
c1b0c88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,12 +14,13 @@ use futures::{ | |
| stream::{self, BoxStream}, | ||
| }; | ||
| use object_store::{ | ||
| Attribute, AttributeValue, Attributes, BackoffConfig, CredentialProvider, GetOptions, | ||
| ObjectMeta, ObjectStore, PutMode, PutOptions, PutPayload, RetryConfig, | ||
| StaticCredentialProvider, UpdateVersion, | ||
| Attribute, AttributeValue, Attributes, BackoffConfig, ClientConfigKey, | ||
| CredentialProvider, GetOptions, ObjectMeta, ObjectStore, PutMode, PutOptions, | ||
| PutPayload, RetryConfig, StaticCredentialProvider, UpdateVersion, | ||
| aws::AmazonS3Builder, | ||
| azure::{AzureConfigKey, MicrosoftAzureBuilder}, | ||
| gcp::{GcpCredential, GoogleCloudStorageBuilder, GoogleConfigKey}, | ||
| http::HttpBuilder, | ||
| local::LocalFileSystem, | ||
| memory::InMemory, | ||
| path::Path as ObjectPath, | ||
|
|
@@ -278,7 +279,7 @@ impl private::Sealed for ObjectStorage {} | |
| #[typetag::serde] | ||
| impl Storage for ObjectStorage { | ||
| fn can_write(&self) -> bool { | ||
| true | ||
| self.backend.can_write() | ||
| } | ||
|
|
||
| #[instrument(skip_all)] | ||
|
|
@@ -653,6 +654,10 @@ pub trait ObjectStoreBackend: Debug + Display + Sync + Send { | |
| } | ||
|
|
||
| fn default_settings(&self) -> Settings; | ||
|
|
||
| fn can_write(&self) -> bool { | ||
| true | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
|
|
@@ -756,6 +761,80 @@ impl ObjectStoreBackend for LocalFileSystemObjectStoreBackend { | |
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub struct HttpObjectStoreBackend { | ||
| pub url: String, | ||
| pub config: Option<HashMap<ClientConfigKey, String>>, | ||
| } | ||
|
|
||
| impl fmt::Display for HttpObjectStoreBackend { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| write!( | ||
| f, | ||
| "HttpObjectStoreBackend(url={}, config={})", | ||
| self.url, | ||
| self.config | ||
| .as_ref() | ||
| .map(|c| c | ||
| .iter() | ||
| .map(|(k, v)| format!("{:?}={}", k, v)) | ||
| .collect::<Vec<_>>() | ||
| .join(", ")) | ||
| .unwrap_or("None".to_string()) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[typetag::serde(name = "http_object_store_provider")] | ||
| impl ObjectStoreBackend for HttpObjectStoreBackend { | ||
| fn mk_object_store( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would need to override the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| &self, | ||
| settings: &Settings, | ||
| ) -> Result<Arc<dyn ObjectStore>, StorageError> { | ||
| let builder = HttpBuilder::new().with_url(&self.url); | ||
|
|
||
| // Add options | ||
| let builder = self | ||
| .config | ||
| .as_ref() | ||
| .unwrap_or(&HashMap::new()) | ||
| .iter() | ||
| .fold(builder, |builder, (key, value)| builder.with_config(*key, value)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mpiannucci can you use the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
|
||
| let builder = builder.with_retry(RetryConfig { | ||
| backoff: BackoffConfig { | ||
| init_backoff: core::time::Duration::from_millis( | ||
| settings.retries().initial_backoff_ms() as u64, | ||
| ), | ||
| max_backoff: core::time::Duration::from_millis( | ||
| settings.retries().max_backoff_ms() as u64, | ||
| ), | ||
| base: 2., | ||
| }, | ||
| max_retries: settings.retries().max_tries().get() as usize - 1, | ||
| retry_timeout: core::time::Duration::from_secs(5 * 60), | ||
| }); | ||
|
|
||
| let store = | ||
| builder.build().map_err(|e| StorageErrorKind::Other(e.to_string()))?; | ||
|
|
||
| Ok(Arc::new(store)) | ||
| } | ||
|
|
||
| fn prefix(&self) -> String { | ||
| "".to_string() | ||
| } | ||
|
|
||
| fn default_settings(&self) -> Settings { | ||
| Default::default() | ||
| } | ||
|
|
||
| fn can_write(&self) -> bool { | ||
| // TODO: Support write operations? | ||
| false | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub struct S3ObjectStoreBackend { | ||
| bucket: String, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.