-
Notifications
You must be signed in to change notification settings - Fork 187
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
Added increment_ratelimit #313
base: main
Are you sure you want to change the base?
Conversation
(converting to draft as I have not yet been able to run the tests, I'll try again when I get home just to make sure it passes and works fine) |
Hi @jsocol, I have added the Thanks
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some unrelated whitespace changes, but otherwise this looks good.
Note: I'm not a maintainer, only @jsocol can approve and merge PRs as far as I know. I know this is a pretty old PR I just happened to stumble upon it.
Thanks @jaap3 😄 |
I added an
increment_ratelimit
function to just increment the group ratelimit count.This is practically just an alias of
is_ratelimited
but makes more sense in terms of its name. Takes only request and group (should I add keys, and fn too?) and returns the count of limits on return (can be a boolean True if successful instead if preferred). This was suggested in #308 as it makes more logical sense to call a function to "increment" the ratelimit rather than call "is_ratelimited" if you're just incrementing it.Where would this be useful?
Well in situations like unsuccessful login attempts, in the logic for your function you may want to add 1 to the count (in this case you dont use decorators), so you need to call a function.
This snippet makes a little more sense then this snippet (logically)
Closes issue: #308