Class ResilienceConfiguration.RateLimiterConfiguration
java.lang.Object
com.sap.cloud.sdk.cloudplatform.resilience.ResilienceConfiguration.RateLimiterConfiguration
- Enclosing class:
- ResilienceConfiguration
Provides options specific to rate limits.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondisabled()
Creates a newRateLimiterConfiguration
that allows for infinite amount of requests, effectively disabling the rate limiter.boolean
int
hashCode()
boolean
Get the status indicator for RateLimiter.int
The number of permissions available during one limit refresh period.The period of a limit refresh.of()
Creates a newRateLimiterConfiguration
with default values of DEFAULT_TIMEOUT_DURATION, DEFAULT_LIMIT_REFRESH_PERIOD and DEFAULT_LIMIT_FOR_PERIODCreates a newRateLimiterConfiguration
by specifying a timeout duration, limit refresh period and limit for period.The wait time a thread waits for a permission.
-
Field Details
-
DEFAULT_TIMEOUT_DURATION
The default wait time a thread waits for a permission. -
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_PERIODThe 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
Creates a newRateLimiterConfiguration
that allows for infinite amount of requests, effectively disabling the rate limiter.- Returns:
- A disabled rate limiter.
-
of
Creates a newRateLimiterConfiguration
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 newRateLimiterConfiguration
by specifying a timeout duration, limit refresh period and limit for period.- Parameters:
timeoutDuration
- The maximum duration a thread waits for a permission to executelimitRefreshPeriod
- The time window in which requests are counted.limitForPeriod
- The maximum number of request allowed during one window.- Returns:
- An immutable
RateLimiterConfiguration
.
-
equals
-
hashCode
public int hashCode() -
timeoutDuration
The wait time a thread waits for a permission. -
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.
-