Record Class RateLimitGuard.RateLimitInfo
java.lang.Object
java.lang.Record
org.apache.juneau.rest.server.guard.RateLimitGuard.RateLimitInfo
- Record Components:
key- The per-request key (e.g. remote address, principal name).limit- The bucket capacity (also reported asX-RateLimit-Limit).remaining- Tokens remaining after this acquisition attempt. Zero when the request was rejected.secondsUntilReset- Seconds until the bucket is full again (also reported asX-RateLimit-Reset).allowed-true if the request was admitted;false if the bucket was empty.
- Enclosing class:
- RateLimitGuard
public static record RateLimitGuard.RateLimitInfo(String key, int limit, int remaining, long secondsUntilReset, boolean allowed)
extends Record
Snapshot of rate-limit state passed to the
onLimitExceeded
callback and used to populate advisory response headers.-
Constructor Summary
ConstructorsConstructorDescriptionRateLimitInfo(String key, int limit, int remaining, long secondsUntilReset, boolean allowed) Creates an instance of aRateLimitInforecord class. -
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.key()Returns the value of thekeyrecord component.intlimit()Returns the value of thelimitrecord component.intReturns the value of theremainingrecord component.longReturns the value of thesecondsUntilResetrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RateLimitInfo
Creates an instance of aRateLimitInforecord class.- Parameters:
key- the value for thekeyrecord componentlimit- the value for thelimitrecord componentremaining- the value for theremainingrecord componentsecondsUntilReset- the value for thesecondsUntilResetrecord componentallowed- the value for theallowedrecord 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
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 '=='. -
key
Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-
limit
Returns the value of thelimitrecord component.- Returns:
- the value of the
limitrecord component
-
remaining
Returns the value of theremainingrecord component.- Returns:
- the value of the
remainingrecord component
-
secondsUntilReset
Returns the value of thesecondsUntilResetrecord component.- Returns:
- the value of the
secondsUntilResetrecord component
-
allowed
Returns the value of theallowedrecord component.- Returns:
- the value of the
allowedrecord component
-