Record Class RateLimiter.RateLimitPolicy.FixedWindow
java.lang.Object
java.lang.Record
com.loomcache.server.network.RateLimiter.RateLimitPolicy.FixedWindow
- Record Components:
requestsPerWindow- max requests in windowwindowDuration- window duration
- All Implemented Interfaces:
RateLimiter.RateLimitPolicy
- Enclosing interface:
RateLimiter.RateLimitPolicy
public static record RateLimiter.RateLimitPolicy.FixedWindow(long requestsPerWindow, Duration windowDuration)
extends Record
implements RateLimiter.RateLimitPolicy
Fixed window policy: allow X requests per window duration.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface RateLimiter.RateLimitPolicy
RateLimiter.RateLimitPolicy.FixedWindow, RateLimiter.RateLimitPolicy.SlidingWindow, RateLimiter.RateLimitPolicy.TokenBucket -
Constructor Summary
ConstructorsConstructorDescriptionFixedWindow(long requestsPerWindow, Duration windowDuration) Creates an instance of aFixedWindowrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of therequestsPerWindowrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thewindowDurationrecord component.
-
Constructor Details
-
FixedWindow
Creates an instance of aFixedWindowrecord class.- Parameters:
requestsPerWindow- the value for therequestsPerWindowrecord componentwindowDuration- the value for thewindowDurationrecord component
-
-
Method Details
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
requestsPerWindow
public long requestsPerWindow()Returns the value of therequestsPerWindowrecord component.- Returns:
- the value of the
requestsPerWindowrecord component
-
windowDuration
Returns the value of thewindowDurationrecord component.- Returns:
- the value of the
windowDurationrecord component
-