Add Extensions in *Result objects#743
Conversation
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_response_extensions_propagated() { |
There was a problem hiding this comment.
This is the only test. Not sure if you want to clutter up the other ones with tests as well. Can do so if desired.
There was a problem hiding this comment.
I think we should add coverage of all new code, otherwise we coudl potentially break this feature in some future refactoring but not know
Not sure if you want to clutter up the other ones
I agree this test seems like a lot of boilerplate setup. It would be nice to avoid that
How about writing something similar to
arrow-rs-object-store/src/integration.rs
Lines 51 to 53 in e89f62b
And then calling it with an existing fixture, like
arrow-rs-object-store/src/aws/mod.rs
Lines 688 to 689 in a9a83f1
| #[cfg(any(feature = "aws", feature = "gcp", feature = "azure"))] | ||
| pub(crate) fn get_put_result( | ||
| headers: &HeaderMap, | ||
| response: crate::client::HttpResponse, |
There was a problem hiding this comment.
Different ways to tackle this. LMK if you prefer another approach. Fable initially did a mut here which was kinda gross.
alamb
left a comment
There was a problem hiding this comment.
Thanks @criccomini -- this looks good to me, other than I think we need test coverage for each object store. I left a suggestion, Let me know what you think
| /// response, allowing custom HTTP middleware to propagate information to callers. | ||
| /// | ||
| /// These extensions are excluded from [`PartialEq`] and [`Eq`]. | ||
| pub extensions: Extensions, |
There was a problem hiding this comment.
this is technically a breaking API change (but that is ok as we are about to release a breaking release)
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_response_extensions_propagated() { |
There was a problem hiding this comment.
I think we should add coverage of all new code, otherwise we coudl potentially break this feature in some future refactoring but not know
Not sure if you want to clutter up the other ones
I agree this test seems like a lot of boilerplate setup. It would be nice to avoid that
How about writing something similar to
arrow-rs-object-store/src/integration.rs
Lines 51 to 53 in e89f62b
And then calling it with an existing fixture, like
arrow-rs-object-store/src/aws/mod.rs
Lines 688 to 689 in a9a83f1
| /// | ||
| /// HTTP-backed stores in this crate populate this with the extensions of the HTTP | ||
| /// response, allowing custom HTTP middleware to propagate information to callers. | ||
| pub extensions: http::Extensions, |
There was a problem hiding this comment.
Given that ListResult already has Extensions -- does it add additional value to add extensions to the PaginatedListResult as well?
|
Great! I'll fix things up. 😀 |
|
Seems like the failed tests are flakes/unrelated to this PR? |
Unrelated to the PR for sure. I'll check them out |
alamb
left a comment
There was a problem hiding this comment.
Looks great to me -- thank you @criccomini
The MSRV check seems to be failing on installing cargo-msrv so that is unrelated to this PR
| s3_encryption(&integration).await; | ||
| put_get_attributes(&integration).await; | ||
| list_paginated(&integration, &integration).await; | ||
| response_extensions(&integration, true).await; |
Which issue does this PR close?
Extensionsin*Resultobjects #740Rationale for this change
We make extensive use of
ObjectStorewrappers that do things like caching, metrics tracking, handle retries, and so on. We've found it would be helpful to useExtensionsnot just for requests (which are already supported today), but also responses.One example: we have a
CachedObjectStorein SlateDB that we are going to make pluggable. We have an internal metrics wrapper that (among other things) tracks cache hits/misses. Now that we're exposing the cache publicly, we need a way for our wrapper to track whether the reads were a hit or miss. AnExtensionsin theResultseems appropriate here. Then users that implement a cache can use the extension to signal such information.This is just one example.
What changes are included in this PR?
Adds a public extensions: http::Extensions field to the existing result types (GetResult, PutResult, ListResult, and PaginatedListResult) mirroring the extensions field already present on the options structs (GetOptions, PutOptions, etc.). This gives ObjectStore implementations (e.g. caching wrappers) a way to return context-specific information, such as cache hit/miss status, to callers.
I did not add
Extensionssupport for Delete/Head as there aren'tResulttypes for these right now. That seemed like a heavier change.Are there any user-facing changes?
WARN: This was coded with Claude Fable with some steering from me. I (a human) wrote this PR summary.