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

Add unit multiplier #552

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

harpunius
Copy link

@harpunius harpunius commented Apr 6, 2024

Implements the unit multiplier idea suggested in #190.

rate_limit:
  unit: <second, minute, hour, day>
  requests_per_unit: <uint>
  unit_multiplier: <uint | optional>

I chose to force unit multiplier to 1 if the value is unset to avoid if/else checks whenever we rely on the value or log anything. This means the PR got slightly bigger than intended, but I think it's nicer.

The config parser panics if unit_multiplier: 0 is set. One RFC is the TODO in UnitToDividerWithMultiplier where I added a redundant if-zero runtime check to make sure we don't multiply by zero and effectively disable the rate limiting.

Note, this is a draft and doesn't build due to the dependencies on both https://github.com/envoyproxy/go-control-plane/blob/main/envoy/service/ratelimit/v3/rls.pb.go#L357-L367 and https://github.com/envoyproxy/go-control-plane/blob/main/ratelimit/config/ratelimit/v3/rls_conf.pb.go#L246-L263. I opened an issue to track this: envoyproxy/envoy#33277.

I couldn't run the integration tests locally (WSL setup) so let me know if we need to extend those tests as well.

Happy to hear your thoughts.

Tobias Sommer added 2 commits April 9, 2024 22:57
Signed-off-by: Tobias Sommer <harpunius@gmail.com>
Signed-off-by: Tobias Sommer <harpunius@gmail.com>
Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label May 10, 2024
@harpunius
Copy link
Author

Not stale. Still waiting for input from e.g. @mattklein123

@github-actions github-actions bot removed the stale label May 13, 2024
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

1 participant