Skip to content

Commit

Permalink
feat(throttle): add constructor for compatibility (#1164)
Browse files Browse the repository at this point in the history
Signed-off-by: Shichao Nie <[email protected]>
  • Loading branch information
SCNieh authored Apr 24, 2024
1 parent c7370bd commit 56e726b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ public class AsyncNetworkBandwidthLimiter {
private long availableExtraTokens;

public AsyncNetworkBandwidthLimiter(Type type, long tokenSize, int refillIntervalMs) {
this(type, tokenSize, refillIntervalMs, tokenSize);
}

public AsyncNetworkBandwidthLimiter(Type type, long tokenSize, int refillIntervalMs, long maxTokens) {
this.type = type;
this.extraTokenSize = (long) (tokenSize * DEFAULT_EXTRA_TOKEN_RATIO);
this.tokenSize = tokenSize - extraTokenSize;
this.availableTokens = this.tokenSize;
this.maxTokens = tokenSize;
this.maxTokens = maxTokens;
this.queuedCallbacks = new PriorityQueue<>();
this.refillThreadPool = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("refill-bucket-thread"));
this.callbackThreadPool = Executors.newFixedThreadPool(1, new DefaultThreadFactory("callback-thread"));
Expand Down

0 comments on commit 56e726b

Please sign in to comment.