Package io.smallrye.faulttolerance.api
Enum RateLimitType
- java.lang.Object
-
- java.lang.Enum<RateLimitType>
-
- io.smallrye.faulttolerance.api.RateLimitType
-
- All Implemented Interfaces:
Serializable,Comparable<RateLimitType>
public enum RateLimitType extends Enum<RateLimitType>
Type of the time window used for rate limiting.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FIXEDDivides time into non-overlapping intervals of given length (time windows) and enforces the invocation limit for each interval independently.ROLLINGEnforces the limit continuously, instead of dividing time into independent windows.SMOOTHCalculates the maximum rate of invocations from given time window length and given limit and enforces a uniform distribution of invocations over time under the calculated rate.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RateLimitTypevalueOf(String name)Returns the enum constant of this type with the specified name.static RateLimitType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FIXED
public static final RateLimitType FIXED
Divides time into non-overlapping intervals of given length (time windows) and enforces the invocation limit for each interval independently. This means that short bursts of invocations occuring near the time window boundaries may temporarily exceed the configured rate limit.This is also called fixed window rate limiting.
Requires constant memory and time.
-
ROLLING
public static final RateLimitType ROLLING
Enforces the limit continuously, instead of dividing time into independent windows. The invocation limit is enforced for all possible time intervals of given length, regardless of overlap.This is also called sliding log rate limiting.
Requires memory and time proportional to the maximum number of invocations in the time window, due to the need to store and check timestamps of recent invocations.
-
SMOOTH
public static final RateLimitType SMOOTH
Calculates the maximum rate of invocations from given time window length and given limit and enforces a uniform distribution of invocations over time under the calculated rate. If recent rate of invocations is under the limit, a subsequent burst of invocations is allowed during a shorter time span, but the calculated rate is never exceeded.This is also called token bucket or leaky bucket (as a meter) rate limiting, with the additional property that all work units are considered to have the same size.
Requires constant memory and time.
-
-
Method Detail
-
values
public static RateLimitType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RateLimitType c : RateLimitType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RateLimitType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-