Enum RateLimitType

java.lang.Object
java.lang.Enum<RateLimitType>
io.smallrye.faulttolerance.api.RateLimitType
All Implemented Interfaces:
Serializable, Comparable<RateLimitType>, java.lang.constant.Constable

public enum RateLimitType extends Enum<RateLimitType>
Type of the time window used for rate limiting.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Divides time into non-overlapping intervals of given length (time windows) and enforces the invocation limit for each interval independently.
    Enforces the limit continuously, instead of dividing time into independent windows.
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this type with the specified name.
    static RateLimitType[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • 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 Details

    • values

      public static RateLimitType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      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 name
      NullPointerException - if the argument is null