Record Class RateLimit.Decision

java.lang.Object
java.lang.Record
com.jsgalactic.axiom.security.RateLimit.Decision
Record Components:
allowed - whether the request fits the budget
limit - requests allowed per window
remaining - requests still allowed now, after this one when allowed
retryAfter - how long to wait before a request would be allowed; zero when allowed
reset - time until the budget is fully restored (bucket) or the window turns (sliding)
Enclosing class:
RateLimit

public static record RateLimit.Decision(boolean allowed, long limit, long remaining, Duration retryAfter, Duration reset) extends Record
The outcome of counting one request.
  • Constructor Details

    • Decision

      public Decision(boolean allowed, long limit, long remaining, Duration retryAfter, Duration reset)
      Creates an instance of a Decision record class.
      Parameters:
      allowed - the value for the allowed record component
      limit - the value for the limit record component
      remaining - the value for the remaining record component
      retryAfter - the value for the retryAfter record component
      reset - the value for the reset record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • allowed

      public boolean allowed()
      Returns the value of the allowed record component.
      Returns:
      the value of the allowed record component
    • limit

      public long limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component
    • remaining

      public long remaining()
      Returns the value of the remaining record component.
      Returns:
      the value of the remaining record component
    • retryAfter

      public Duration retryAfter()
      Returns the value of the retryAfter record component.
      Returns:
      the value of the retryAfter record component
    • reset

      public Duration reset()
      Returns the value of the reset record component.
      Returns:
      the value of the reset record component