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

feat: automatically handle helix rate limits #306

Merged
merged 1 commit into from Apr 27, 2021

Conversation

iProdigy
Copy link
Member

@iProdigy iProdigy commented Apr 7, 2021

Prerequisites for Code Changes

  • This pull request follows the code style of the project
  • I have tested this feature

Changes Proposed

  • Track api bucket point usage of the user/app access token(s) in TwitchHelixClientIdInterceptor
  • Create a custom JacksonDecoder to track ratelimit headers received by twitch to ensure our bucket cache is in harmony
  • Delegate http calls in TwitchHelixHttpClient immediately or with delay, depending on the amount of points left in the corresponding bucket

@iProdigy
Copy link
Member Author

iProdigy commented Apr 8, 2021

The main downside of this approach: https://github.com/twitch4j/twitch4j/blob/feature/helix-rate-limiting/rest-helix/src/main/java/com/github/twitch4j/helix/interceptor/TwitchHelixHttpClient.java#L51

  • withTimeout needs to be high enough for the call not to fail while waiting for bucket headroom
  • the waiting is blocking rather than via elegant executor scheduling

Unfortunately, I'm not sure if feign/hystrix allows a better way

@iProdigy iProdigy merged commit 68bfe14 into develop Apr 27, 2021
@iProdigy iProdigy deleted the feature/helix-rate-limiting branch April 27, 2021 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants