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

fix: change refill strategy for API rate limiting #3949

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Mono<Response> isAllowed(String routeId, String id) {
}

private Bucket newBucket(String id) {
Bandwidth limit = Bandwidth.builder().capacity(capacity).refillGreedy(tokens, Duration.ofMinutes(refillDuration)).build();
Bandwidth limit = Bandwidth.builder().capacity(capacity).refillIntervally(tokens, Duration.ofMinutes(refillDuration)).build();
return Bucket.builder().addLimit(limit).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.zowe.apiml.util.categories.RateLimitTest;
import org.zowe.apiml.util.http.HttpRequestUtils;
import reactor.netty.http.client.HttpClient;

import javax.net.ssl.SSLException;

@RateLimitTest
public class InMemoryRateLimiterFilterFactoryIntegrationTest {

private static WebTestClient client;
Expand All @@ -33,7 +35,7 @@ public class InMemoryRateLimiterFilterFactoryIntegrationTest {
@BeforeAll
static void setUpTester() {
String baseUrl = HttpRequestUtils.getUriFromGateway("/discoverableclient/api/v1/greeting").toString();
SslContext sslContext = null;
SslContext sslContext;
try {
sslContext = SslContextBuilder
.forClient()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/

package org.zowe.apiml.util.categories;
import org.junit.jupiter.api.Tag;

import java.lang.annotation.*;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;

/**
* Test related to the API Rate limiting.
*/
@Tag("RateLimitTest")
@Target({ TYPE, METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface RateLimitTest {
}
Loading