Package com.jsgalactic.axiom.security
Record Class RateLimit.Decision
java.lang.Object
java.lang.Record
com.jsgalactic.axiom.security.RateLimit.Decision
- Record Components:
allowed- whether the request fits the budgetlimit- requests allowed per windowremaining- requests still allowed now, after this one when allowedretryAfter- how long to wait before a request would be allowed; zero when allowedreset- 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowed()Returns the value of theallowedrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longlimit()Returns the value of thelimitrecord component.longReturns the value of theremainingrecord component.reset()Returns the value of theresetrecord component.Returns the value of theretryAfterrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Decision
Creates an instance of aDecisionrecord class.- Parameters:
allowed- the value for theallowedrecord componentlimit- the value for thelimitrecord componentremaining- the value for theremainingrecord componentretryAfter- the value for theretryAfterrecord componentreset- the value for theresetrecord component
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
allowed
public boolean allowed()Returns the value of theallowedrecord component.- Returns:
- the value of the
allowedrecord component
-
limit
public long limit()Returns the value of thelimitrecord component.- Returns:
- the value of the
limitrecord component
-
remaining
public long remaining()Returns the value of theremainingrecord component.- Returns:
- the value of the
remainingrecord component
-
retryAfter
Returns the value of theretryAfterrecord component.- Returns:
- the value of the
retryAfterrecord component
-
reset
Returns the value of theresetrecord component.- Returns:
- the value of the
resetrecord component
-