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

[FEATURE] Support rate limiting of APIs #190

Open
dogawaf opened this issue May 30, 2023 · 2 comments
Open

[FEATURE] Support rate limiting of APIs #190

dogawaf opened this issue May 30, 2023 · 2 comments

Comments

@dogawaf
Copy link
Contributor

dogawaf commented May 30, 2023

While integrating Twitter API v2, I was facing quite a restrictive rate limits:

Twitter's documentation is not accurate and mention limits that are not observed in the real life. For example, with a Basic tier, I was expecting a 1500 requests / 15 min for the timeline endpoint, but in fact, the limit is 10 requests / 15 minutes!

Anyway, I've implemented a rate limiting support for Twitter v2 into the extension, in order to get the right numbers from the response's headers, and to pause the import task until the rate limit get reset.

See the attached patch:
pxasocialfeed_retry_429.patch.txt

It offers a generic way for integrators to hook into the error handling during the import of a feed.
Then, a new exception can be returned in order to retry the import, with a hard limit of 5 retry.

Here is an example of the slot handling the rate limiting of Twitter v2:
ImportFeedSlot.php.txt

If the approach is good for you, I can make a pull request.

@MattiasNilsson
Copy link
Contributor

@dogawaf This looks great and I would appreciate a PR :)

@dogawaf
Copy link
Contributor Author

dogawaf commented Oct 8, 2024

Hi

I will make a PR in a few days.

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

2 participants