Repository navigation
Conversation
Hetzner reports its rate limit state in RateLimit-* headers on every response, but the generated client discarded all headers, so callers could only react after a 429. Error responses now carry the headers in ResponseContent. Each operation gets an <op>_with_headers sibling that returns the headers next to the model; the existing function wraps it and keeps its signature. The headers are boxed to keep the Err variant small. Adding a field to ResponseContent is a breaking change for code that builds it with a struct literal or destructures it without `..`. Regenerating templates.diff also picks up the #[serde(untagged)] change to model.mustache, which the diff file was missing. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
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.
Hetzner reports the rate limit in
RateLimit-LimitandRateLimit-Remainingon every response, and this PR lets callers read those headers. Until now the generated client dropped all headers, so a caller learned about the limit only from a 429. In #43 I asked which shape you'd prefer and went with one of them here. If you want the other one, say so and I'll redo it.The change has two parts:
headersfield onResponseContent. It is aBox<HeaderMap>, because without the box theErrvariant goes over clippy'sresult_large_errlimit on every operation.<op>_with_headersfunction that returns(model, HeaderMap). The existing function calls it and drops the headers, so its signature doesn't change.This is a breaking change for code that builds
ResponseContentwith a struct literal or destructures it without... Everything else compiles as before.The templates carry the whole change:
api.mustache, plus a newapi_mod.mustacheoverride. Everything undersrc/apisis a plain regeneration with generator 7.7.0 and spec d47f7a2, so it doesn't need a line-by-line read. Regenerating main with no template changes gives an empty diff. Regeneratingtemplates.diffalso brought in the#[serde(untagged)]hunk from 150a035, which the file was missing.The new test points the client at a local TCP listener that sends a canned response. It checks the headers on a 200 with a body, on a 204 without one, and on a 429. Clippy reports the same warnings as on main.
Closes #43