-
Notifications
You must be signed in to change notification settings - Fork 4
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
issues/235: Improve precision to ratelimiting #239
Conversation
komuw
commented
Mar 2, 2023
•
edited
Loading
edited
- Fixes: ratelimiting starts too early #235
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #239 +/- ##
=======================================
Coverage 77.59% 77.59%
=======================================
Files 34 34
Lines 3156 3156
=======================================
Hits 2449 2449
Misses 593 593
Partials 114 114
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
middleware/ratelimiter.go
Outdated
if alw { | ||
t.messagesDelivered = t.messagesDelivered + 1 | ||
t.tokens = t.tokens - 1 | ||
} else { | ||
t.limit() | ||
} |
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.
One effect of this new change is that if rate_limit = 100/sec and then you send requests that are equal to or less than 100, all of them will be let in immediately without delay.