This is an automated email from the ASF dual-hosted git repository.

mneumann pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 8df892b21b feat: add `Extensions` to object store `GetOptions` (#7170)
8df892b21b is described below

commit 8df892b21bbff0c423f7da153db4cdf98012bb5c
Author: Marco Neumann <[email protected]>
AuthorDate: Thu Feb 27 15:02:23 2025 +0100

    feat: add `Extensions` to object store `GetOptions` (#7170)
    
    * feat: add `Extensions` to object store `GetOptions`
    
    Closes #7155.
    
    * refactor: replace own `Extensions` by `http` version
    
    * feat: wire `Extensions` into HTTP stack
---
 object_store/Cargo.toml            |  4 ++--
 object_store/src/client/builder.rs |  7 +++++++
 object_store/src/client/mod.rs     | 23 ++++++++++++++++++-----
 object_store/src/lib.rs            |  5 +++++
 4 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/object_store/Cargo.toml b/object_store/Cargo.toml
index 7e51245834..0372514dba 100644
--- a/object_store/Cargo.toml
+++ b/object_store/Cargo.toml
@@ -34,6 +34,7 @@ async-trait = "0.1.53"
 bytes = "1.0"
 chrono = { version = "0.4.34", default-features = false, features = ["clock"] }
 futures = "0.3"
+http = "1.2.0"
 humantime = "2.1"
 itertools = "0.14.0"
 parking_lot = { version = "0.12" }
@@ -46,7 +47,6 @@ walkdir = { version = "2", optional = true }
 # Cloud storage support
 base64 = { version = "0.22", default-features = false, features = ["std"], 
optional = true }
 form_urlencoded = { version = "1.2", optional = true }
-http = { version = "1.2.0", optional = true }
 http-body-util = { version = "0.1", optional = true }
 httparse = { version = "1.8.0", default-features = false, features = ["std"], 
optional = true }
 hyper = { version = "1.2", default-features = false, optional = true }
@@ -66,7 +66,7 @@ nix = { version = "0.29.0", features = ["fs"] }
 
 [features]
 default = ["fs"]
-cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", 
"reqwest/stream", "chrono/serde", "base64", "rand", "ring", "dep:http", 
"http-body-util", "form_urlencoded", "serde_urlencoded"]
+cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", 
"reqwest/stream", "chrono/serde", "base64", "rand", "ring", "http-body-util", 
"form_urlencoded", "serde_urlencoded"]
 azure = ["cloud", "httparse"]
 fs = ["walkdir"]
 gcp = ["cloud", "rustls-pemfile"]
diff --git a/object_store/src/client/builder.rs 
b/object_store/src/client/builder.rs
index 0fbc12fd94..fcbc6e8bae 100644
--- a/object_store/src/client/builder.rs
+++ b/object_store/src/client/builder.rs
@@ -92,6 +92,13 @@ impl HttpRequestBuilder {
         self
     }
 
+    pub(crate) fn extensions(mut self, extensions: ::http::Extensions) -> Self 
{
+        if let Ok(r) = &mut self.request {
+            *r.extensions_mut() = extensions;
+        }
+        self
+    }
+
     pub(crate) fn header<K, V>(mut self, name: K, value: V) -> Self
     where
         K: TryInto<HeaderName>,
diff --git a/object_store/src/client/mod.rs b/object_store/src/client/mod.rs
index 4fe3cff159..36252f54f1 100644
--- a/object_store/src/client/mod.rs
+++ b/object_store/src/client/mod.rs
@@ -718,27 +718,40 @@ impl GetOptionsExt for HttpRequestBuilder {
     fn with_get_options(mut self, options: GetOptions) -> Self {
         use hyper::header::*;
 
-        if let Some(range) = options.range {
+        let GetOptions {
+            if_match,
+            if_none_match,
+            if_modified_since,
+            if_unmodified_since,
+            range,
+            version: _,
+            head: _,
+            extensions,
+        } = options;
+
+        if let Some(range) = range {
             self = self.header(RANGE, range.to_string());
         }
 
-        if let Some(tag) = options.if_match {
+        if let Some(tag) = if_match {
             self = self.header(IF_MATCH, tag);
         }
 
-        if let Some(tag) = options.if_none_match {
+        if let Some(tag) = if_none_match {
             self = self.header(IF_NONE_MATCH, tag);
         }
 
         const DATE_FORMAT: &str = "%a, %d %b %Y %H:%M:%S GMT";
-        if let Some(date) = options.if_unmodified_since {
+        if let Some(date) = if_unmodified_since {
             self = self.header(IF_UNMODIFIED_SINCE, 
date.format(DATE_FORMAT).to_string());
         }
 
-        if let Some(date) = options.if_modified_since {
+        if let Some(date) = if_modified_since {
             self = self.header(IF_MODIFIED_SINCE, 
date.format(DATE_FORMAT).to_string());
         }
 
+        self = self.extensions(extensions);
+
         self
     }
 }
diff --git a/object_store/src/lib.rs b/object_store/src/lib.rs
index 58f757b297..21352f5761 100644
--- a/object_store/src/lib.rs
+++ b/object_store/src/lib.rs
@@ -967,6 +967,11 @@ pub struct GetOptions {
     ///
     /// <https://datatracker.ietf.org/doc/html/rfc9110#name-head>
     pub head: bool,
+    /// Implementation-specific extensions. Intended for use by 
[`ObjectStore`] implementations
+    /// that need to pass context-specific information (like tracing spans) 
via trait methods.
+    ///
+    /// These extensions are ignored entirely by backends offered through this 
crate.
+    pub extensions: ::http::Extensions,
 }
 
 impl GetOptions {

Reply via email to