Class RateLimiterConfig.Builder

java.lang.Object
io.github.resilience4j.ratelimiter.RateLimiterConfig.Builder
Enclosing class:
RateLimiterConfig

public static class RateLimiterConfig.Builder extends Object
  • Constructor Details

  • Method Details

    • build

      public RateLimiterConfig build()
      Builds a RateLimiterConfig
      Returns:
      the RateLimiterConfig
    • writableStackTraceEnabled

      public RateLimiterConfig.Builder writableStackTraceEnabled(boolean 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

      public RateLimiterConfig.Builder timeoutDuration(Duration 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

      public RateLimiterConfig.Builder limitRefreshPeriod(Duration limitRefreshPeriod)
      Configures the period of limit refresh. After each period rate limiter sets its permissions count to RateLimiterConfig.limitForPeriod value. Default value is 500 nanoseconds.
      Parameters:
      limitRefreshPeriod - the period of limit refresh
      Returns:
      the RateLimiterConfig.Builder
    • limitForPeriod

      public RateLimiterConfig.Builder limitForPeriod(int limitForPeriod)
      Configures the permissions limit for refresh period. Count of permissions available during one rate limiter period specified by RateLimiterConfig.limitRefreshPeriod value. Default value is 50.
      Parameters:
      limitForPeriod - the permissions limit for refresh period
      Returns:
      the RateLimiterConfig.Builder