Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit baeede9

Browse files
Merge pull request #274 from lowcoder-org/configurable_ratelimit_threshold
Make default API rate limit configurable
2 parents 45d3dfb + 09b58c4 commit baeede9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/filter/ThrottlingFilter.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import lombok.extern.slf4j.Slf4j;
77
import org.lowcoder.sdk.config.dynamic.ConfigCenter;
88
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.beans.factory.annotation.Value;
910
import org.springframework.core.Ordered;
1011
import org.springframework.http.server.reactive.ServerHttpRequest;
1112
import org.springframework.stereotype.Component;
@@ -30,8 +31,10 @@
3031
@Component
3132
public class ThrottlingFilter implements WebFilter, Ordered {
3233

33-
private static final int DEFAULT_RATE_THRESHOLD = 50;
34+
@Value("${default.apiRateLimit:50}")
35+
private int defaultApiRateLimit;
3436

37+
3538
private final Map<String, RateLimiterWrapper> rateLimiterMap = new ConcurrentHashMap<>();
3639
private Supplier<Map<String, Integer>> urlRateLimiter;
3740

@@ -52,7 +55,7 @@ public Mono<Void> filter(@Nonnull ServerWebExchange exchange, @Nonnull WebFilter
5255

5356
RateLimiterWrapper rateLimiter = rateLimiterMap.compute(requestUrl,
5457
(url, currentLimiter) -> {
55-
int targetRate = urlRateLimiter.get().getOrDefault(url, DEFAULT_RATE_THRESHOLD);
58+
int targetRate = urlRateLimiter.get().getOrDefault(url, defaultApiRateLimit);
5659
if (currentLimiter == null) {
5760
return RateLimiterWrapper.create(targetRate);
5861
}

‎server/api-service/lowcoder-server/src/main/resources/application-lowcoder.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ default:
2929
org-group-count: 100
3030
org-app-count: 1000
3131
developer-count: 50
32+
api-rate-limit: 50
3233

3334
common:
3435
cookie-name: LOCAL_LOWCODER_TOKEN

‎server/api-service/lowcoder-server/src/main/resources/selfhost/ce/application.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ default:
2929
org-group-count: 100
3030
org-app-count: 1000
3131
developer-count: 50
32+
api-rate-limit: 50
3233

3334
common:
3435
cookie-name: LOWCODER_CE_SELFHOST_TOKEN

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /