-
Notifications
You must be signed in to change notification settings - Fork 643
Add a "minimal crate metadata" API endpoint #4548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a "minimal crate metadata" API endpoint #4548
Conversation
As mentioned in rust-lang#4503 and renovatebot/renovate#3486, this is intended to be a lighter-weight API than /crates/:crate_id, which can be subject to looser rate limits.
I'm not quite sure about where the rate limits come from, I assume |
Thanks @teozkr Yes, the rate limit is not enforced in code. Let's see what others say, this adds an additional endpoint while the original compromise called for an additional parameter on the existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can split them into a separate PR, if you prefer that
that would be great, yeah 👍 ideally two separate PRs since the two changes are itself unrelated too :)
This adds a new
/crates/:crate_id/crate
endpoint for metadata about the crate itself, without information about related objects (such as versions or categories).
IMHO having two endpoints for the same resource makes it a bit confusing. was there a reason why you went that way instead of optimizing the existing endpoint?
could you also make sure to add a few tests for the new code? 🙏
To me, "overview of X and subresources" and "info about X" are two fairly separate code paths. A client would also want to have completely separate type definitions for them, for example. There's also the server code structure issue, that doing it as a separate flag for |
1a8524d
to
29c21f5
Compare
Explicitly specify the branch name in init-local-index.sh Otherwise the script breaks if `init.defaultBranch` is not set to `master` (with `main` becoming a common alternative these days). Split out from #4548.
Fix clippy warnings Split out from #4548
Added a test based on the full metadata endpoint test. Ideally it'd validate that we only make one DB query, but it doesn't look like Diesel has a way to query for that, as far as I can tell. |
I tend to disagree. That endpoint is returning a resource and in the default case it currently includes a bunch of related resources (aka. relationships). The suggestion in the in linked issue was to make that automatic relationship inclusion opt-out. Having two different endpoint for the same resource may make it easier right now to implement things, but it also means we have to maintain two different endpoints that basically do the same thing. I'd prefer to be able to use something like https://jsonapi.org/format/#fetching-includes, even though we're currently not using the JSON:API schema for our responses. |
Okay, b9c7fff merges the 28ead19 takes this a bit further, and breaks |
I think I like the second approch to allow retrieving specific data. |
Yes, ~1 additional database query is performed per extra include that the user requests. This already happened before this PR, the PR just makes those queries conditional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me overall. Just one minor nit in the wording of an error message. Thanks!
This looks excellent, thanks! |
Thanks! @bors r+ |
📌 Commit fae83f1 has been approved by |
☀️ Test successful - checks-actions |
As mentioned in #4503 and renovatebot/renovate#3486, this is intended to be a lighter-weight API than
/crates/:crate_id
, which can be subject to looser rate limits.This adds a new
/crates/:crate_id/crate
endpoint for metadata about the crate itself, without information about related objects (such as versions or categories).