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

Rate-limit if increment > remaining limit #29

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Rate-limit if increment > remaining limit #29

merged 1 commit into from
Jul 24, 2024

Conversation

VojtechVitek
Copy link
Contributor

Do not allow requests with an increment higher than the remaining limit.

Example: A request with an increment of 100 should not be allowed if the remaining limit is only 99. However, other requests with an increment of 1 can still pass through.

Comment on lines -63 to -66
name: "no-block",
name: "no limit",
increment: 0,
requestsLimit: 3,
windowLength: 4 * time.Second,
respCodes: []int{200, 200, 429},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has changed:

with increment = 2 and limit = 3,

the httprate middleware used to allow two requests in row

but with this change, it only allows one request

@VojtechVitek VojtechVitek merged commit fb7d30a into master Jul 24, 2024
1 check passed
@VojtechVitek VojtechVitek deleted the ciJYwFZ5 branch July 24, 2024 11:19
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.

1 participant