Skip to content

Commit 8df892b

Browse files
authored
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
1 parent 2fd5181 commit 8df892b

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

object_store/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async-trait = "0.1.53"
3434
bytes = "1.0"
3535
chrono = { version = "0.4.34", default-features = false, features = ["clock"] }
3636
futures = "0.3"
37+
http = "1.2.0"
3738
humantime = "2.1"
3839
itertools = "0.14.0"
3940
parking_lot = { version = "0.12" }
@@ -46,7 +47,6 @@ walkdir = { version = "2", optional = true }
4647
# Cloud storage support
4748
base64 = { version = "0.22", default-features = false, features = ["std"], optional = true }
4849
form_urlencoded = { version = "1.2", optional = true }
49-
http = { version = "1.2.0", optional = true }
5050
http-body-util = { version = "0.1", optional = true }
5151
httparse = { version = "1.8.0", default-features = false, features = ["std"], optional = true }
5252
hyper = { version = "1.2", default-features = false, optional = true }
@@ -66,7 +66,7 @@ nix = { version = "0.29.0", features = ["fs"] }
6666

6767
[features]
6868
default = ["fs"]
69-
cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", "reqwest/stream", "chrono/serde", "base64", "rand", "ring", "dep:http", "http-body-util", "form_urlencoded", "serde_urlencoded"]
69+
cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", "reqwest/stream", "chrono/serde", "base64", "rand", "ring", "http-body-util", "form_urlencoded", "serde_urlencoded"]
7070
azure = ["cloud", "httparse"]
7171
fs = ["walkdir"]
7272
gcp = ["cloud", "rustls-pemfile"]

object_store/src/client/builder.rs

+7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ impl HttpRequestBuilder {
9292
self
9393
}
9494

95+
pub(crate) fn extensions(mut self, extensions: ::http::Extensions) -> Self {
96+
if let Ok(r) = &mut self.request {
97+
*r.extensions_mut() = extensions;
98+
}
99+
self
100+
}
101+
95102
pub(crate) fn header<K, V>(mut self, name: K, value: V) -> Self
96103
where
97104
K: TryInto<HeaderName>,

object_store/src/client/mod.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -718,27 +718,40 @@ impl GetOptionsExt for HttpRequestBuilder {
718718
fn with_get_options(mut self, options: GetOptions) -> Self {
719719
use hyper::header::*;
720720

721-
if let Some(range) = options.range {
721+
let GetOptions {
722+
if_match,
723+
if_none_match,
724+
if_modified_since,
725+
if_unmodified_since,
726+
range,
727+
version: _,
728+
head: _,
729+
extensions,
730+
} = options;
731+
732+
if let Some(range) = range {
722733
self = self.header(RANGE, range.to_string());
723734
}
724735

725-
if let Some(tag) = options.if_match {
736+
if let Some(tag) = if_match {
726737
self = self.header(IF_MATCH, tag);
727738
}
728739

729-
if let Some(tag) = options.if_none_match {
740+
if let Some(tag) = if_none_match {
730741
self = self.header(IF_NONE_MATCH, tag);
731742
}
732743

733744
const DATE_FORMAT: &str = "%a, %d %b %Y %H:%M:%S GMT";
734-
if let Some(date) = options.if_unmodified_since {
745+
if let Some(date) = if_unmodified_since {
735746
self = self.header(IF_UNMODIFIED_SINCE, date.format(DATE_FORMAT).to_string());
736747
}
737748

738-
if let Some(date) = options.if_modified_since {
749+
if let Some(date) = if_modified_since {
739750
self = self.header(IF_MODIFIED_SINCE, date.format(DATE_FORMAT).to_string());
740751
}
741752

753+
self = self.extensions(extensions);
754+
742755
self
743756
}
744757
}

object_store/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,11 @@ pub struct GetOptions {
967967
///
968968
/// <https://datatracker.ietf.org/doc/html/rfc9110#name-head>
969969
pub head: bool,
970+
/// Implementation-specific extensions. Intended for use by [`ObjectStore`] implementations
971+
/// that need to pass context-specific information (like tracing spans) via trait methods.
972+
///
973+
/// These extensions are ignored entirely by backends offered through this crate.
974+
pub extensions: ::http::Extensions,
970975
}
971976

972977
impl GetOptions {

0 commit comments

Comments
 (0)