Class ResilienceConfiguration.RateLimiterConfiguration

java.lang.Object
com.sap.cloud.sdk.cloudplatform.resilience.ResilienceConfiguration.RateLimiterConfiguration
Enclosing class:
ResilienceConfiguration

public static final class ResilienceConfiguration.RateLimiterConfiguration extends Object
Provides options specific to rate limits.
  • Field Details

    • DEFAULT_TIMEOUT_DURATION

      public static final Duration DEFAULT_TIMEOUT_DURATION
      The default wait time a thread waits for a permission.
    • DEFAULT_LIMIT_REFRESH_PERIOD

      public static final Duration DEFAULT_LIMIT_REFRESH_PERIOD
      The default period of a limit refresh. After each period the rate limiter sets its permissions count back to the limitForPeriod value.
    • DEFAULT_LIMIT_FOR_PERIOD

      public static final int DEFAULT_LIMIT_FOR_PERIOD
      The default number of permissions available during one limit refresh period.
      See Also:
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Get the status indicator for RateLimiter.
      Returns:
      True if the configuration is enabled.
    • disabled

      @Nonnull public static ResilienceConfiguration.RateLimiterConfiguration disabled()
      Creates a new RateLimiterConfiguration that allows for infinite amount of requests, effectively disabling the rate limiter.
      Returns:
      A disabled rate limiter.
    • of

      Creates a new RateLimiterConfiguration with default values of DEFAULT_TIMEOUT_DURATION, DEFAULT_LIMIT_REFRESH_PERIOD and DEFAULT_LIMIT_FOR_PERIOD
      Returns:
      An immutable RateLimiterConfiguration.
    • of

      @Nonnull public static ResilienceConfiguration.RateLimiterConfiguration of(@Nonnull Duration timeoutDuration, @Nonnull Duration limitRefreshPeriod, int limitForPeriod)
      Creates a new RateLimiterConfiguration by specifying a timeout duration, limit refresh period and limit for period.
      Parameters:
      timeoutDuration - The maximum duration a thread waits for a permission to execute
      limitRefreshPeriod - The time window in which requests are counted.
      limitForPeriod - The maximum number of request allowed during one window.
      Returns:
      An immutable RateLimiterConfiguration.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • timeoutDuration

      @Nonnull public Duration timeoutDuration()
      The wait time a thread waits for a permission.
    • limitRefreshPeriod

      @Nonnull public Duration limitRefreshPeriod()
      The period of a limit refresh. After each period the rate limiter sets its permissions count back to the limitForPeriod value.
    • limitForPeriod

      public int limitForPeriod()
      The number of permissions available during one limit refresh period.