Skip to content

Commit

Permalink
Minor refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinomso Ikwuagwu committed Jan 21, 2024
1 parent aef71ec commit 8f3a438
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,24 @@ protected void initFilterBean() throws ServletException {

super.initFilterBean();

if (rateLimiterFactory != null) {
return;
}

WebRateLimiterContext context = rateLimiterContextBuilder().build();

if (webRateLimiterRegistry == null) {
webRateLimiterRegistry = rateLimiterRegistry(context);
}

if (rateLimiterFactory != null) {
return;
}
rateLimiterFactory = webRateLimiterRegistry.createRateLimiterFactory();

if (!context.hasRateSources()) {
rateLimiterFactory = RateLimiterFactory.noop();
} else {
rateLimiterFactory = webRateLimiterRegistry.createRateLimiterFactory();
}
LOG.info(webRateLimiterRegistry.isRateLimitingEnabled()
? "Completed setup of automatic rate limiting" : "Rate limiting is disabled");
}

protected WebRateLimiterRegistry rateLimiterRegistry(WebRateLimiterContext config) {
return WebRateLimiterRegistrySpring.of(config);
protected WebRateLimiterRegistry rateLimiterRegistry(WebRateLimiterContext context) {
return WebRateLimiterRegistrySpring.of(context);
}

protected WebRateLimiterContext.Builder rateLimiterContextBuilder() {
Expand Down

0 comments on commit 8f3a438

Please sign in to comment.