Package io.smallrye.faulttolerance.api
Interface Guard.Builder.RateLimitBuilder
- Enclosing interface:
Guard.Builder
public static interface Guard.Builder.RateLimitBuilder
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 Guard.Builder.RateLimitBuilderwith(Consumer<Guard.Builder.RateLimitBuilder> 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
- See Also:
-
window
Sets the time window length. Defaults to 1 second.- Parameters:
value- the time window size, must be >= 1- Returns:
- this rate limit builder
- See Also:
-
minSpacing
Sets the minimum spacing between invocations. Defaults to 0.- Parameters:
value- the minimum spacing, must be >= 0- Returns:
- this rate limit builder
- See Also:
-
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
- See Also:
-
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
Guard.Builder done()Returns the original fault tolerance builder.- Returns:
- the original fault tolerance builder
-
with
-