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

    Constructors
    Constructor
    Description
    TokenBucketStatus(int maxRequests, long availableRequests, int maxTokens, long availableTokens, Instant lastRefill)
    Creates an instance of a TokenBucketStatus record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the availableRequests record component.
    long
    Returns the value of the availableTokens record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    hasCapacity(int estimatedTokens)
    True if there is room for a request consuming the given token estimate.
    final int
    Returns a hash code value for this object.
    Returns the value of the lastRefill record component.
    int
    Returns the value of the maxRequests record component.
    int
    Returns the value of the maxTokens record component.
    One-line human-readable description of the limiter's current state.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TokenBucketStatus

      public TokenBucketStatus(int maxRequests, long availableRequests, int maxTokens, long availableTokens, Instant lastRefill)
      Creates an instance of a TokenBucketStatus record class.
      Parameters:
      maxRequests - the value for the maxRequests record component
      availableRequests - the value for the availableRequests record component
      maxTokens - the value for the maxTokens record component
      availableTokens - the value for the availableTokens record component
      lastRefill - the value for the lastRefill record component
  • Method Details

    • hasCapacity

      public boolean hasCapacity(int estimatedTokens)
      True if there is room for a request consuming the given token estimate.
    • summary

      public String summary()
      Description copied from interface: RateLimiterStatus
      One-line human-readable description of the limiter's current state. Used for logging and monitoring dashboards.
      Specified by:
      summary in interface RateLimiterStatus
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxRequests

      public int maxRequests()
      Returns the value of the maxRequests record component.
      Returns:
      the value of the maxRequests record component
    • availableRequests

      public long availableRequests()
      Returns the value of the availableRequests record component.
      Returns:
      the value of the availableRequests record component
    • maxTokens

      public int maxTokens()
      Returns the value of the maxTokens record component.
      Returns:
      the value of the maxTokens record component
    • availableTokens

      public long availableTokens()
      Returns the value of the availableTokens record component.
      Returns:
      the value of the availableTokens record component
    • lastRefill

      public Instant lastRefill()
      Returns the value of the lastRefill record component.
      Returns:
      the value of the lastRefill record component