Skip to content
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

Improve handling of rate limiting #73

Open
torfsen opened this issue Aug 26, 2023 · 0 comments
Open

Improve handling of rate limiting #73

torfsen opened this issue Aug 26, 2023 · 0 comments

Comments

@torfsen
Copy link
Contributor

torfsen commented Aug 26, 2023

In torfsen/roux-stream#12, a user's code crashed with hard-to-understand error messages that originated from Serde not being able to decode a response of the comments API endpoint. The underlying reason was that the user violated Reddit's rate limits (which have been made more strict in July 2023), so the API returned an HTTP 429 ("Too many requests") response that Serde then unsurprisingly failed to parse as comment data.

Since dealing with rate limiting is a common issue in automated API clients, it would be nice if roux would provide better support here (both the user and roux-stream have no better way of handling this problem on their own, since roux does not expose any details about the process).

In particular, it would be great if roux

  1. Checked for HTTP 429 responses and propagated them in a suitable form. Alternatively and probably even better, any HTTP error response should be propagated (e.g. via reqwest's Response.raise_for_status) instead of trying to parse it as JSON as usual.
  2. Exposed the rate limiting information that the API provides via the X-Ratelimit-* HTTP headers (see the Reddit API rules). For example, the Subreddit methods could parse that information from the headers and store it in the Subreddit struct.
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

No branches or pull requests

1 participant