Make default hitsAddend minimum value configurable #729
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.
fix: #730
In the current implementation of the
ratelimit
service, thehitsAddend
value that is associated with each request is set to a minimum of1
.This is done to ensure that if the
RateLimit
request does not specify anyrequest.hitsAddend
(like what the envoy ratelimit filter does by default if no envoy.ratelimit.hits_addend has been defined), the hit is still counted.This minimum
hitsAddend
of1
is enforced via aMax(1, <hitsAddend from request>)
function.This PR adds the possibility to configure the minimum value of the
hitsAddend
via a settings, so0
can also be used as minimumhitsAddend
value if needed. The current behavior of1
being the default value is preserved, and if the environment variable is not set, then a value of1
is applied, like currently.The ability to configure a minimum
hitsAddend
to zero can help for example for the following use cases:RateLimitRequest
to check the current remaining rates without consuming a quota (e.g.: Add a way to check rate limits without using quota #244)1
value to the real weight defined ashitsAddend
.