Record Class TokenBucketStatus
java.lang.Object
java.lang.Record
ai.redouble.nucleo.harness.admission.TokenBucketStatus
- All Implemented Interfaces:
RateLimiterStatus
public record TokenBucketStatus(int maxRequests, long availableRequests, int maxTokens, long availableTokens, Instant lastRefill)
extends Record
implements RateLimiterStatus
Status snapshot for a token-bucket rate limiter with dual request/token buckets.
Used by token-bucket LLM rate limiters (requests per minute + tokens per minute). Exposes the available capacity in both buckets, computed from the clock at the instant the snapshot was taken.
- Since:
- 0.1 (2026-04-13)
- Author:
- Andrey Santrosyan
-
Constructor Summary
ConstructorsConstructorDescriptionTokenBucketStatus(int maxRequests, long availableRequests, int maxTokens, long availableTokens, Instant lastRefill) Creates an instance of aTokenBucketStatusrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of theavailableRequestsrecord component.longReturns the value of theavailableTokensrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanhasCapacity(int estimatedTokens) True if there is room for a request consuming the given token estimate.final inthashCode()Returns a hash code value for this object.Returns the value of thelastRefillrecord component.intReturns the value of themaxRequestsrecord component.intReturns the value of themaxTokensrecord component.summary()One-line human-readable description of the limiter's current state.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TokenBucketStatus
public TokenBucketStatus(int maxRequests, long availableRequests, int maxTokens, long availableTokens, Instant lastRefill) Creates an instance of aTokenBucketStatusrecord class.- Parameters:
maxRequests- the value for themaxRequestsrecord componentavailableRequests- the value for theavailableRequestsrecord componentmaxTokens- the value for themaxTokensrecord componentavailableTokens- the value for theavailableTokensrecord componentlastRefill- the value for thelastRefillrecord component
-
-
Method Details
-
hasCapacity
public boolean hasCapacity(int estimatedTokens) True if there is room for a request consuming the given token estimate. -
summary
Description copied from interface:RateLimiterStatusOne-line human-readable description of the limiter's current state. Used for logging and monitoring dashboards.- Specified by:
summaryin interfaceRateLimiterStatus
-
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. -
maxRequests
public int maxRequests()Returns the value of themaxRequestsrecord component.- Returns:
- the value of the
maxRequestsrecord component
-
availableRequests
public long availableRequests()Returns the value of theavailableRequestsrecord component.- Returns:
- the value of the
availableRequestsrecord component
-
maxTokens
public int maxTokens()Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
availableTokens
public long availableTokens()Returns the value of theavailableTokensrecord component.- Returns:
- the value of the
availableTokensrecord component
-
lastRefill
Returns the value of thelastRefillrecord component.- Returns:
- the value of the
lastRefillrecord component
-