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

issues/235: Improve precision to ratelimiting #239

Merged
merged 13 commits into from
Mar 2, 2023
Merged

issues/235: Improve precision to ratelimiting #239

merged 13 commits into from
Mar 2, 2023

Conversation

komuw
Copy link
Owner

@komuw komuw commented Mar 2, 2023

@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2023

Codecov Report

Patch coverage: 87.50% and no project coverage change

Comparison is base (d34dc73) 77.59% compared to head (93ca5f8) 77.59%.

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           
Impacted Files Coverage Δ
internal/clientip/client_ip.go 72.46% <0.00%> (ø)
middleware/ratelimiter.go 94.25% <100.00%> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 143 to 148
if alw {
t.messagesDelivered = t.messagesDelivered + 1
t.tokens = t.tokens - 1
} else {
t.limit()
}
Copy link
Owner Author

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.

@komuw komuw marked this pull request as ready for review March 2, 2023 11:00
@komuw komuw changed the title issues/235-c issues/235: Improve precision to ratelimiting Mar 2, 2023
@komuw komuw merged commit 343119a into main Mar 2, 2023
@komuw komuw deleted the issues/235-c branch March 2, 2023 14:54
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.

ratelimiting starts too early
2 participants