T
- result type@ThreadSafe public class InvocationLimiter<T> extends Object
Concurrent access to the same resource is allowed. In case of reaching the limit of invocation in a period of time, the result will contain information when the next invocation can be performed for this resource.
InvocationLimiterResponse
Constructor and Description |
---|
InvocationLimiter(int invocationLimit,
int invocationLimitUnitCount,
@NotNull TimeUnit invocationLimitUnit) |
Modifier and Type | Method and Description |
---|---|
<V> @NotNull InvocationLimiterResponse<V> |
invoke(T resource,
@NotNull Supplier<V> invocation)
Try to invoke a given resource.
|
void |
resetSettings(int limit,
int invocationLimitUnitCount,
@NotNull TimeUnit invocationLimitUnit)
Resets settings for limiter, removes all data about past invocation and start counting invocation from 0.
|
public InvocationLimiter(int invocationLimit, int invocationLimitUnitCount, @NotNull @NotNull TimeUnit invocationLimitUnit)
@NotNull public <V> @NotNull InvocationLimiterResponse<V> invoke(@NotNull T resource, @NotNull @NotNull Supplier<V> invocation)
V
- type of responseresource
- key of the resource for which to measure invocationsinvocation
- action which should be invokedpublic void resetSettings(int limit, int invocationLimitUnitCount, @NotNull @NotNull TimeUnit invocationLimitUnit)
limit
- new limitinvocationLimitUnitCount
- new limit unit countinvocationLimitUnit
- new limit unitCopyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.