Feature: WithResetOnSuccessfulCall Option#48
Open
3choBoomer wants to merge 2 commits intogofri:mainfrom
Open
Conversation
add option to reset category on successful response
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.
Feature:
WithResetOnSuccessfulCallOptionThis PR introduces a new request option,
WithResetOnSuccessfulCall, designed to handle discrepancies between the client-side rate limiter and the actual GitHub API state.Problem:
This transport could be stacked with others, including an auth management transport like https://github.com/bored-engineer/github-rate-limit-http-transport. Continuing to wait on non-rate-limited responses would continue blocking when there could potentially be tokens available downstream.
Solution:
The
WithResetOnSuccessfulCalloption allows an application to send a "probe" request.github_primary_ratelimitwill reset the tracking state for that specific resource category.Usage:
This is best used in conjunction with
WithLimitBypasson a single request to periodically probe a blocked category to see if the rate limit on the server side has actually expired or if the client was mistakenly blocking.parseRequestCategorylogic:github_primary_ratelimit/category.goto userequest.URL.Pathinstead ofrequest.URL.RawPath.RawPathis often empty in Go'snet/urlwhen the path contains no characters requiring special encoding. This caused standard endpoints (like/search) to fail string matching and incorrectly default to thecorelimit category.Pathis the reliable field for routing logic.