Class RateLimiterRegistry
java.lang.Object
ai.redouble.nucleo.harness.admission.RateLimiterRegistry
Lookup facade for per-model accounts: the
TokenBucketRateLimiter of an entry
bounded by a quota window, the ModelGate of an entry bounded by a concurrency.
Shared across all clients of a given model so global limits are honored even when many
jobs use the same model concurrently. Delegates to RateLimiterFactory for the
actual creation and lifecycle.- Since:
- 0.1 (2025-08-12)
- Author:
- Andrey Santrosyan
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all rate limiters (useful for testing).Gets or creates the gate for a model whose entry declaresmax_concurrent.static RateLimiterRegistryGets the singleton instance.getRateLimiter(ModelSpec model) Gets or creates a rate limiter for the given model.Gets the current status of a model's rate limiter.voidupdateLimits(ModelSpec model, int requestsPerMinute, int tokensPerMinute) Updates rate limits based on actual API response headers.
-
Method Details
-
getInstance
Gets the singleton instance. -
getRateLimiter
Gets or creates a rate limiter for the given model.- Parameters:
model- the model- Returns:
- the rate limiter for this model
-
gate
-
updateLimits
Updates rate limits based on actual API response headers. This allows dynamic adjustment based on real limits.- Parameters:
model- the modelrequestsPerMinute- new RPM limittokensPerMinute- new TPM limit
-
getStatus
Gets the current status of a model's rate limiter. -
clear
public void clear()Clears all rate limiters (useful for testing).
-