Skip to content

Commit

Permalink
#424 - Replace deprecated calls to bucket4j library
Browse files Browse the repository at this point in the history
- replace calls to Bandwith constructor with BandwithBuilder
- replace oauth token request constructor call with call to builder
  • Loading branch information
michael-82 committed Jan 13, 2025
1 parent 7f998bc commit 5792b49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public String getToken() {

private HTTPRequest getTokenRequest() throws GeneralException, IOException {
if (tokenRequest == null) {
tokenRequest = new TokenRequest(getTokenUri(), clientAuth, new ClientCredentialsGrant()).toHTTPRequest();
tokenRequest = new TokenRequest.Builder(getTokenUri(), clientAuth, new ClientCredentialsGrant())
.build().toHTTPRequest();
}
return tokenRequest;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.numcodex.feasibility_gui_backend.query.ratelimiting;

import io.github.bucket4j.Bandwidth;
import io.github.bucket4j.BandwidthBuilder;
import io.github.bucket4j.Bucket;
import io.github.bucket4j.Refill;
import lombok.Getter;
Expand Down Expand Up @@ -62,19 +63,19 @@ public void addTokensToDetailedObfuscatedResultBucket(String userId, int amount)

private Bucket newSummaryResultBucket(String userId) {
return Bucket.builder()
.addLimit(Bandwidth.classic(1, Refill.intervally(1, intervalPollingSummary)))
.addLimit(limit -> limit.capacity(1).refillIntervally(1, intervalPollingSummary))
.build();
}

private Bucket newDetailedResultBucket(String userId) {
return Bucket.builder()
.addLimit(Bandwidth.classic(1, Refill.intervally(1, intervalPollingDetailed)))
.addLimit(limit -> limit.capacity(1).refillIntervally(1, intervalPollingDetailed))
.build();
}

private Bucket newViewDetailedObfuscatedResultBucket(String userId) {
return Bucket.builder()
.addLimit(Bandwidth.classic(amountDetailedObfuscated, Refill.intervally(1, intervalDetailedObfuscated)))
.addLimit(limit -> limit.capacity(1).refillIntervally(1, intervalDetailedObfuscated))
.build();
}

Expand Down

0 comments on commit 5792b49

Please sign in to comment.