Open
Conversation
…Client that cannot be throttled but still counts towards some limits, contractual, performance, etc. Two paths two different applications, especially on shared keys.
DamianFekete
reviewed
Nov 2, 2020
|
|
||
| /** | ||
| * Regardless of being over limit, we still want to track the count, this is for a client that is going to act | ||
| * regardless of a limit, but, still needs to be counted towareds said limit. |
DamianFekete
reviewed
Nov 2, 2020
| } | ||
|
|
||
| private boolean eqOrGeLimit(String key, int weight, boolean strictlyGreater) { | ||
| private boolean eqOrGeLimit(String key, int weight, boolean strictlyGreater, boolean increment_anyway) { |
There was a problem hiding this comment.
increment_anyway -> incrementAnyway
For me alwaysIncrement sounds better.
DamianFekete
reviewed
Nov 2, 2020
Comment on lines
+92
to
+95
|
|
||
|
|
||
|
|
||
|
|
DamianFekete
reviewed
Nov 2, 2020
|
|
||
| private boolean eqOrGeLimit(String key, int weight, boolean strictlyGreater) { | ||
| // Chris Fauerbach, adding a way to override the increment even if over limit | ||
| // @chrisfauerbach , https://fauie.com , github.com/chrisfauerbach |
DamianFekete
reviewed
Nov 2, 2020
| return true; // over limit, don't record request | ||
| if (increment_regardless) { | ||
| geLimit = true; | ||
| }else { |
DamianFekete
reviewed
Nov 2, 2020
| // Counter should be 0 now | ||
| assertThat(requestRateLimiter.overLimitWhenIncremented(key, 1)).isFalse(); | ||
| // Counter should be 1 now and 'false', meaning not over limit | ||
| LOG.debug("About to print add 10 to go over."); |
There was a problem hiding this comment.
IMHO the log debug messages are not needed, and they could be Java comments if they bring any value
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.
I have the use case need to increment my counter, even if I'm over limit. I added another parameter to 'increment anyway', and also added convenience methods.
Tests written and verified in: hazelcast, memory, redis.
Please let me know if there are any questions!