Skip to content

feat: introduce rest catalog cache primitives - #372

Merged
JanKaul merged 5 commits into
JanKaul:mainfrom
splitgraph:rest-cache-primitives
Jul 15, 2026
Merged

feat: introduce rest catalog cache primitives#372
JanKaul merged 5 commits into
JanKaul:mainfrom
splitgraph:rest-cache-primitives

Conversation

@gruuya

@gruuya gruuya commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Progresses #268.

This PR adds new primitives for handling the HTTP cache semantics when loading a table:

  • new Conditional enum in the rest crate
  • generalizing fetch, so that it can accommodate both LoadTableResult and Conditional<LoadTableResult> via
  • a new FromResponse trait
  • (drive-by) fetch and fetch_empty are consolidated to remove code duplication.

Finally, this is also exposed at the catalog_api_api::load_table level, which now accepts headers, and can return Conditional::NotModified when a If-None-Match headers is passed, end the ETag is still matching.

gruuya and others added 2 commits July 13, 2026 15:57
…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
@JanKaul

JanKaul commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Thanks a lot for the PR. IT would be great to get this in.

I've made a PR splitgraph#23 where a refactored the FromResponse trait into a inner and wrapper function. I would like to avoid using a trait for this.

JanKaul and others added 2 commits July 15, 2026 11:14
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.
…rait

refactor: replace FromResponse trait with fetch_inner + fetch_conditi…
@JanKaul

JanKaul commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Sorry for the linting issues I pushed to the other PR.

@JanKaul

JanKaul commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Otherwise looks good to me.

@gruuya

gruuya commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the linting issues I pushed to the other PR.

no worries, lint fixes pushed.

@JanKaul
JanKaul merged commit 20363b4 into JanKaul:main Jul 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants