Record Class RateLimiter.RateLimitPolicy.TokenBucket
java.lang.Object
java.lang.Record
com.loomcache.server.network.RateLimiter.RateLimitPolicy.TokenBucket
- Record Components:
tokensPerSecond- generation rateburstCapacity- maximum tokens
- All Implemented Interfaces:
RateLimiter.RateLimitPolicy
- Enclosing interface:
RateLimiter.RateLimitPolicy
public static record RateLimiter.RateLimitPolicy.TokenBucket(double tokensPerSecond, double burstCapacity)
extends Record
implements RateLimiter.RateLimitPolicy
Token bucket policy: accumulate tokens at specified rate, burst capacity.
- 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
ConstructorsConstructorDescriptionTokenBucket(double tokensPerSecond, double burstCapacity) Creates an instance of aTokenBucketrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theburstCapacityrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.doubleReturns the value of thetokensPerSecondrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TokenBucket
public TokenBucket(double tokensPerSecond, double burstCapacity) Creates an instance of aTokenBucketrecord class.- Parameters:
tokensPerSecond- the value for thetokensPerSecondrecord componentburstCapacity- the value for theburstCapacityrecord 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. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
tokensPerSecond
public double tokensPerSecond()Returns the value of thetokensPerSecondrecord component.- Returns:
- the value of the
tokensPerSecondrecord component
-
burstCapacity
public double burstCapacity()Returns the value of theburstCapacityrecord component.- Returns:
- the value of the
burstCapacityrecord component
-