Package com.google.gerrit.server.quota
Interface QuotaBackend
- All Known Implementing Classes:
DefaultQuotaBackend
public interface QuotaBackend
Backend interface to perform quota requests on. By default, this interface is backed by
DefaultQuotaBackend
which calls all plugins that implement QuotaEnforcer
. A different
implementation might be bound in tests. Plugins are not supposed to implement this interface, but
bind a QuotaEnforcer
implementation instead.
All quota requests require a quota group and a user. Enriching them with a top-level entity
Change, Project, Account
is optional but should be done if the request is targeted.
Example usage:
quotaBackend.currentUser().project(projectName).requestToken("/projects/create").throwOnError(); quotaBackend.user(user).requestToken("/restapi/config/put").throwOnError(); QuotaResponse.Aggregated result = quotaBackend.currentUser().account(accountId).requestToken("/restapi/accounts/emails/validate"); QuotaResponse.Aggregated result = quotaBackend.currentUser().project(projectName).requestTokens("/projects/git/upload", numBytesInPush);
All quota groups must be documented in quota.txt
and detail the metadata that is
provided (i.e. the parameters used to scope down the quota request).
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
An interface capable of issuing quota requests.static interface
An interface capable of issuing quota requests. -
Method Summary
Modifier and TypeMethodDescriptionConstructs a request for the current user.user
(CurrentUser user) SeecurrentUser()
.
-
Method Details
-
currentUser
QuotaBackend.WithUser currentUser()Constructs a request for the current user. -
user
SeecurrentUser()
. Use this method only if you can't guarantee that the request is for the current user (e.g. impersonation).
-