public class TokenBucketThrottlingStrategy extends Object implements ThrottlingStrategy
Constructor and Description |
---|
TokenBucketThrottlingStrategy(com.google.common.base.Ticker ticker,
ScheduledExecutorService scheduledExecutor,
org.forgerock.util.time.Duration cleaningInterval)
Constructs a new
TokenBucketThrottlingStrategy . |
Modifier and Type | Method and Description |
---|---|
void |
stop()
Stop and free any resources needed by the strategy.
|
org.forgerock.util.promise.Promise<Long,org.forgerock.util.promise.NeverThrowsException> |
throttle(String partitionKey,
ThrottlingRate throttlingRate)
Based on the given partitionKey and throttlingRate, return if the call is accepted or not.
|
public TokenBucketThrottlingStrategy(com.google.common.base.Ticker ticker, ScheduledExecutorService scheduledExecutor, org.forgerock.util.time.Duration cleaningInterval)
TokenBucketThrottlingStrategy
.ticker
- the Ticker
to use to follow the timeline.scheduledExecutor
- the ScheduledExecutorService
used to schedule cleaning tasks.cleaningInterval
- the interval between 2 cleaning tasks.public org.forgerock.util.promise.Promise<Long,org.forgerock.util.promise.NeverThrowsException> throttle(String partitionKey, ThrottlingRate throttlingRate)
ThrottlingStrategy
This method returns a promise as the decision to let this call going through can be queued and thus completed later. That may allow for example to queue the first calls and complete the returned promises at a constant rate.
throttle
in interface ThrottlingStrategy
partitionKey
- the key used to identify the different groupsthrottlingRate
- the throttling rate to applyPromise
meaning that the call is accepted (succeeds with 0) or refused (succeeds with value
greater than 0)public void stop()
ThrottlingStrategy
stop
in interface ThrottlingStrategy
Copyright © 2025 Open Identity Platform Community. All rights reserved.