Package io.smallrye.faulttolerance.api
Interface FaultTolerance.Builder.RateLimitBuilder<T,R>
- Enclosing interface:
FaultTolerance.Builder<T,
R>
public static interface FaultTolerance.Builder.RateLimitBuilder<T,R>
Configures a rate limit.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondone()
Returns the original fault tolerance builder.limit
(int value) Sets the maximum number of invocations in a time window.minSpacing
(long value, ChronoUnit unit) Sets the minimum spacing between invocations.onPermitted
(Runnable callback) Sets a callback that will be invoked when this rate limit permits an invocation.onRejected
(Runnable callback) Sets a callback that will be invoked when this rate limit rejects an invocation.type
(RateLimitType value) Sets the type of time windows used for rate limiting.window
(long value, ChronoUnit unit) Sets the time window length.default FaultTolerance.Builder.RateLimitBuilder
<T, R> with
(Consumer<FaultTolerance.Builder.RateLimitBuilder<T, R>> consumer)
-
Method Details
-
limit
Sets the maximum number of invocations in a time window. Defaults to 100.- Parameters:
value
- maximum number of invocations in a time window, must be >= 1- Returns:
- this rate limit builder
-
window
Sets the time window length. Defaults to 1 second.- Parameters:
value
- the time window size, must be >= 1- Returns:
- this rate limit builder
-
minSpacing
Sets the minimum spacing between invocations. Defaults to 0.- Parameters:
value
- the minimum spacing, must be >= 0- Returns:
- this rate limit builder
-
type
Sets the type of time windows used for rate limiting. Defaults toRateLimitType.FIXED
.- Parameters:
value
- the time window type, must not benull
- Returns:
- this rate limit builder
-
onPermitted
Sets a callback that will be invoked when this rate limit permits an invocation.The callback must be fast and non-blocking and must not throw an exception.
- Parameters:
callback
- the permitted callback, must not benull
- Returns:
- this rate limit builder
-
onRejected
Sets a callback that will be invoked when this rate limit rejects an invocation.The callback must be fast and non-blocking and must not throw an exception.
- Parameters:
callback
- the rejected callback, must not benull
- Returns:
- this rate limit builder
-
done
FaultTolerance.Builder<T,R> done()Returns the original fault tolerance builder.- Returns:
- the original fault tolerance builder
-
with
default FaultTolerance.Builder.RateLimitBuilder<T,R> with(Consumer<FaultTolerance.Builder.RateLimitBuilder<T, R>> consumer)
-