public abstract class AbstractLimiter<In,Out> extends Object
If the number of permits requested at one time is greater than the total number of permits, we will allow this request under the condition that the available permits are equal to the maximum number of permits, i.e., there are no in-flight requests.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractLimiter.RejectedState |
Constructor and Description |
---|
AbstractLimiter(int maxInFlight,
LimitedPolicy policy,
String metricPrefix) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Out> |
acquireAndDo(In in,
java.util.function.Supplier<CompletableFuture<Out>> action)
Acquire permits and do the action.
|
abstract int |
calculatePermits(In in)
Calculate the number of permits to acquire.
|
abstract Out |
rejected(In in,
AbstractLimiter.RejectedState state)
The rejected action.
|
public AbstractLimiter(int maxInFlight, LimitedPolicy policy, String metricPrefix)
public CompletableFuture<Out> acquireAndDo(In in, java.util.function.Supplier<CompletableFuture<Out>> action)
in
- inputaction
- the action to dopublic abstract int calculatePermits(In in)
in
- inputpublic abstract Out rejected(In in, AbstractLimiter.RejectedState state)
in
- inputstate
- the rejected stateCopyright © 2025. All rights reserved.