-
Notifications
You must be signed in to change notification settings - Fork 380
Replace custom token-bucket implementation with Guava's RateLimiter
#3507
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,6 @@ data: | |
| {{- if ne .Values.rateLimiter.type "no-op" -}} | ||
| {{- $_ = set $map "polaris.rate-limiter.token-bucket.type" .Values.rateLimiter.tokenBucket.type -}} | ||
| {{- $_ = set $map "polaris.rate-limiter.token-bucket.requests-per-second" .Values.rateLimiter.tokenBucket.requestsPerSecond -}} | ||
| {{- $_ = set $map "polaris.rate-limiter.token-bucket.window" .Values.rateLimiter.tokenBucket.window -}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will also need to update https://github.com/apache/polaris/blob/main/helm/polaris/tests/configmap_test.yaml:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those are already removed (see below)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed to remove the |
||
| {{- end -}} | ||
|
|
||
| {{- /* Tasks */ -}} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,13 +20,19 @@ | |
|
|
||
| import io.smallrye.config.ConfigMapping; | ||
| import java.time.Duration; | ||
| import java.util.Optional; | ||
|
|
||
| @ConfigMapping(prefix = "polaris.rate-limiter.token-bucket") | ||
| public interface TokenBucketConfiguration { | ||
|
|
||
| /** | ||
| * Number of allowed requests per second per realm. The value <em>must</em> be greater than zero. | ||
| */ | ||
| long requestsPerSecond(); | ||
|
|
||
| Duration window(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be a breaking change if older deployments defined a config value for it in Could we keep a deprecated (in code and in CHANGELOG) receiver just to improve backward compatibility?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-added the |
||
| /** This setting is no longer used and will be removed in a future release. */ | ||
| @Deprecated(since = "1.3.0", forRemoval = true) | ||
| Optional<Duration> window(); | ||
|
|
||
| /** | ||
| * The type of the token bucket factory. Must be a registered {@link | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.polaris.service.ratelimiter; | ||
|
|
||
| import io.smallrye.common.annotation.Identifier; | ||
| import jakarta.enterprise.context.RequestScoped; | ||
|
|
||
| @Identifier("mock") | ||
| @RequestScoped | ||
| public class MockRateLimiter implements RateLimiter { | ||
| public static volatile boolean allowProceed = false; | ||
|
|
||
| @Override | ||
| public boolean canProceed() { | ||
| return allowProceed; | ||
| } | ||
| } |
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.
As this is not a backward compatible change, should we update CHANGELOG.md as well?
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.
Added notes to the CHANGELOG