Package google.registry.proxy.quota
Class QuotaManager
java.lang.Object
google.registry.proxy.quota.QuotaManager
A thread-safe quota manager that schedules background refresh if necessary.
This class abstracts away details about the TokenStore
. It:
- Translates a
QuotaManager.QuotaRequest
to taking one token from the store, blocks the caller, and responds with aQuotaManager.QuotaResponse
. - Translates a
QuotaManager.QuotaRebate
to putting the token to the store asynchronously, and immediately returns. - Periodically refreshes the token records asynchronously to purge stale recodes.
There should be one QuotaManager
per protocol.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Value class representing a quota rebate.static final record
Value class representing a quota request.static final record
Value class representing a quota response. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionacquireQuota
(QuotaManager.QuotaRequest request) Attempts to acquire requested quota, synchronously.Future
<?> releaseQuota
(QuotaManager.QuotaRebate rebate) Returns granted quota to the token store, asynchronously.
-
Constructor Details
-
QuotaManager
-
-
Method Details
-
acquireQuota
Attempts to acquire requested quota, synchronously. -
releaseQuota
Returns granted quota to the token store, asynchronously.
-