Class RateLimiterConfig.Builder
java.lang.Object
io.github.resilience4j.ratelimiter.RateLimiterConfig.Builder
- Enclosing class:
- RateLimiterConfig
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a RateLimiterConfigdrainPermissionsOnResult
(Predicate<io.github.resilience4j.core.functions.Either<? extends Throwable, ?>> drainPermissionsOnResult) Allows you to check the result of a call decorated by this rate limiter and make a decision should we drain all the permissions left it the current period.limitForPeriod
(int limitForPeriod) Configures the permissions limit for refresh period.limitRefreshPeriod
(Duration limitRefreshPeriod) Configures the period of limit refresh.timeoutDuration
(Duration timeoutDuration) Configures the default wait for permission duration.writableStackTraceEnabled
(boolean writableStackTraceEnabled) Enables writable stack traces.
-
Constructor Details
-
Builder
public Builder() -
Builder
-
-
Method Details
-
build
Builds a RateLimiterConfig- Returns:
- the RateLimiterConfig
-
writableStackTraceEnabled
Enables writable stack traces. When set to false,Throwable.getStackTrace()
returns a zero length array. This may be used to reduce log spam when the circuit breaker is open as the cause of the exceptions is already known (the circuit breaker is short-circuiting calls).- Parameters:
writableStackTraceEnabled
- flag to control if stack trace is writable- Returns:
- the BulkheadConfig.Builder
-
drainPermissionsOnResult
public RateLimiterConfig.Builder drainPermissionsOnResult(Predicate<io.github.resilience4j.core.functions.Either<? extends Throwable, ?>> drainPermissionsOnResult) Allows you to check the result of a call decorated by this rate limiter and make a decision should we drain all the permissions left it the current period. Useful in situations when despite using a RateLimiter the underlining called service will say that you passed the maximum number of calls for a given period.- Parameters:
drainPermissionsOnResult
- your function should return true when the permissions drain should happen- Returns:
- the RateLimiterConfig.Builder
- See Also:
-
timeoutDuration
Configures the default wait for permission duration. Default value is 5 seconds.- Parameters:
timeoutDuration
- the default wait for permission duration- Returns:
- the RateLimiterConfig.Builder
-
limitRefreshPeriod
Configures the period of limit refresh. After each period rate limiter sets its permissions count toRateLimiterConfig.limitForPeriod
value. Default value is 500 nanoseconds.- Parameters:
limitRefreshPeriod
- the period of limit refresh- Returns:
- the RateLimiterConfig.Builder
-
limitForPeriod
Configures the permissions limit for refresh period. Count of permissions available during one rate limiter period specified byRateLimiterConfig.limitRefreshPeriod
value. Default value is 50.- Parameters:
limitForPeriod
- the permissions limit for refresh period- Returns:
- the RateLimiterConfig.Builder
-