refactor: replace FromResponse trait with fetch_inner + fetch_conditi… - #23
Merged
gruuya merged 2 commits intoJul 15, 2026
Conversation
…onal - Extract HTTP mechanics into private fetch_inner returning reqwest::Response - fetch becomes a thin wrapper (T: DeserializeOwned), absorbing fetch_empty - fetch_conditional returns Conditional<T> for 304-aware endpoints - Conditional::Modified now carries the full HeaderMap instead of a single extracted etag string, letting callers access any response header - load_table is non-generic, always returns Conditional<LoadTableResult> - No FromResponse trait needed; no fetch_empty function needed
gruuya
approved these changes
Jul 15, 2026
gruuya
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for your suggestions!
Fwiw, my thinking for the (optional) follow-up to this was either:
- expose a
load_tabular_cachedmethod in the catalog, that would acceptetagas another argument (thus delegating caching entirely to the user), or - have
RestCatalogcarry optional metadata cache, exposed via a trait (so that users can control storage/limits/TTL/eviction), but ultimately the cache is owned by theRestCataloginstance. When unset (None) it uses the regular fetch, and whenSome` it uses the conditional one.
I guess this is still doable even with catalog_api_api::load_table always returning a result wrapped in Conditional.
load_table returns LoadTableResult directly — no wrapping, ergonomic for callers that don't need cache semantics. load_table_conditional returns Conditional<LoadTableResult> and is the right call when passing If-None-Match; it can return NotModified. This avoids surprising callers of load_table with a Conditional return type when no If-None-Match header was sent.
Author
|
I really like the second approach. I think it makes sense that the metadata cache should be tied to the catalog instance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on JanKaul#372.
I would like to avoid the FromResponse trait. I refactored the same logic into a
fetch_innermethod and created a fetch_conditional wrapper. I think it should solve the same issue.Additionally extended the Conditional struct to include also other response headers. To be able to use it for vended-credentials.