Class RateLimitInfo
java.lang.Object
ai.redouble.nucleo.harness.admission.RateLimitInfo
- All Implemented Interfaces:
Serializable
Captures rate limit information from API responses.
Immutable data class holding rate limit headers and status.
- Since:
- 0.1 (2025-08-11)
- Author:
- Andrey Santrosyan
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRateLimitInfo(String model, Integer tokensLimit, Integer tokensRemaining, Instant tokensReset, Integer requestsLimit, Integer requestsRemaining, Duration retryAfter, boolean wasRateLimited) RateLimitInfo(String model, Integer tokensLimit, Integer tokensRemaining, Instant tokensReset, Integer requestsLimit, Integer requestsRemaining, Duration retryAfter, boolean wasRateLimited, RateLimitType type) The full record. -
Method Summary
Modifier and TypeMethodDescriptionstatic RateLimitInfofromHeaders(String model, Integer tokensLimit, Integer tokensRemaining, Instant tokensReset) The record a successful response's token headers give: a capacity reading that was not rate limited, with no retry-after and no request limits.getModel()getType()static IntegerparseIntOrNull(String value) Header-value parsing shared by the clients: the value is trimmed, and a missing or non-numeric header is a valid absent value, null.static RateLimitInforateLimited(String model) The minimal record for a limit that was hit and nothing more: no limits known, nothing remaining, a sixty-second retry-after, kind unknown.boolean
-
Field Details
-
requestsPerMinute
public final int requestsPerMinute -
tokensPerMinute
public final int tokensPerMinute
-
-
Constructor Details
-
RateLimitInfo
-
RateLimitInfo
public RateLimitInfo(String model, Integer tokensLimit, Integer tokensRemaining, Instant tokensReset, Integer requestsLimit, Integer requestsRemaining, Duration retryAfter, boolean wasRateLimited, RateLimitType type) The full record. A null kind reads asRateLimitType.UNKNOWN; the per-minute fields mirror the limits and read zero when a limit is absent; the capture instant is now.
-
-
Method Details
-
rateLimited
The minimal record for a limit that was hit and nothing more: no limits known, nothing remaining, a sixty-second retry-after, kind unknown. -
fromHeaders
public static RateLimitInfo fromHeaders(String model, Integer tokensLimit, Integer tokensRemaining, Instant tokensReset) The record a successful response's token headers give: a capacity reading that was not rate limited, with no retry-after and no request limits. -
parseIntOrNull
-
getModel
-
getTokensLimit
-
getTokensRemaining
-
getTokensReset
-
getRequestsLimit
-
getRequestsRemaining
-
getRetryAfter
-
wasRateLimited
public boolean wasRateLimited() -
getCapturedAt
-
getType
-