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

Recompute keys in atomic incr with sliding window #69

Merged
merged 3 commits into from
Apr 17, 2018

Conversation

gdvalle
Copy link
Contributor

@gdvalle gdvalle commented Apr 15, 2018

Change the WindowRateLimiter to pass a callable to incr_and_sum so
that during atomic increments the time windows can be recomputed in the
event of a lock.

This breaks the API because we change incr_and_sum's keys arg to
a callable. We keep backwards compatibility by checking if keys is
callable and calling it on each use.

@@ -100,6 +100,8 @@ def incr_and_sum(self, key, keys, amount, maximum, ttl):
if value > maximum:
return False

# TODO: Drop non-callable keys in Dramatiq v2.
keys = keys() if callable(keys) else keys
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to key_list or something since it's in a loop to avoid shadowing the keys callable.

Change the `WindowRateLimiter` to pass a callable to `incr_and_sum` so
that during atomic increments the time windows can be recomputed in the
event of a lock.

This breaks the API because we change `incr_and_sum`'s `keys` arg to
a callable. We keep backwards compatibility by checking if `keys` is
callable and calling it on each use.
@Bogdanp Bogdanp merged commit 8528e4c into Bogdanp:master Apr 17, 2018
@gdvalle gdvalle deleted the ratelimit-keys branch April 17, 2018 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants