This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Conversation
This file contains 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
Baliedge
force-pushed
the
Baliedge/PIP-2786-drain-remaining
branch
from
January 4, 2024 19:29
ead0fd8
to
8db85a4
Compare
Takumi2008
approved these changes
Jan 5, 2024
Closed
Closed
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
DRAIN_OVER_LIMIT
.golangci-lint
make proto
to build protobufs usingbuf
tool. See: https://buf.build/docs/Users may add behavior
Behavior_DRAIN_OVER_LIMIT
to the rate check request. AGetRateLimits
call drains the remaining counter on first over limit event. Then,successive
GetRateLimits
calls will return zero remaining counter and not anyresidual value. This behavior works best with token bucket algorithm
because the
Remaining
counter will stay zero after an over limit until resettime, whereas leaky bucket algorithm will immediately update
Remaining
to anon-zero value.
This facilitates scenarios that require an over limit event to stay over limit
until the rate limit resets. This approach is necessary if a process must make
two rate checks, before and after a process, and the
Hit
amount is not knownuntil after the process.
GetRateLimits
withHits=0
to check the value ofRemaining
counter. IfRemaining
is zero, it's knownthat the rate limit is depleted and the process can be aborted.
GetRateLimits
with a user specifiedHits
value. Ifthe call returns over limit, the process cannot be aborted because it had
already completed. Using
DRAIN_OVER_LIMIT
behavior, theRemaining
countwill be drained to zero.
Once an over limit occurs in the "After" step, successive processes will detect
the over limit state in the "Before" step.