Documentation ¶
Overview ¶
Package quotapb contains definitions for quota API protos and RPC service. TODO(codingllama): Add a brief explanation of how the quota system works and example configurations.
Package quotapb is a generated protocol buffer package.
It is generated from these files:
quotapb.proto
It has these top-level messages:
Config SequencingBasedStrategy TimeBasedStrategy CreateConfigRequest DeleteConfigRequest GetConfigRequest ListConfigsRequest ListConfigsResponse UpdateConfigRequest
Package quotapb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterQuotaHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterQuotaHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterQuotaServer(s *grpc.Server, srv QuotaServer)
- type Config
- func (*Config) Descriptor() ([]byte, []int)
- func (m *Config) GetCurrentTokens() int64
- func (m *Config) GetMaxTokens() int64
- func (m *Config) GetName() string
- func (m *Config) GetReplenishmentStrategy() isConfig_ReplenishmentStrategy
- func (m *Config) GetSequencingBased() *SequencingBasedStrategy
- func (m *Config) GetState() Config_State
- func (m *Config) GetTimeBased() *TimeBasedStrategy
- func (*Config) ProtoMessage()
- func (m *Config) Reset()
- func (m *Config) String() string
- func (*Config) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type Config_SequencingBased
- type Config_State
- type Config_TimeBased
- type CreateConfigRequest
- type DeleteConfigRequest
- type GetConfigRequest
- type ListConfigsRequest
- type ListConfigsRequest_ListView
- type ListConfigsResponse
- type QuotaClient
- type QuotaServer
- type SequencingBasedStrategy
- type TimeBasedStrategy
- type UpdateConfigRequest
- func (*UpdateConfigRequest) Descriptor() ([]byte, []int)
- func (m *UpdateConfigRequest) GetConfig() *Config
- func (m *UpdateConfigRequest) GetName() string
- func (m *UpdateConfigRequest) GetResetQuota() bool
- func (m *UpdateConfigRequest) GetUpdateMask() *google_protobuf2.FieldMask
- func (*UpdateConfigRequest) ProtoMessage()
- func (m *UpdateConfigRequest) Reset()
- func (m *UpdateConfigRequest) String() string
Constants ¶
This section is empty.
Variables ¶
var Config_State_name = map[int32]string{
0: "UNKNOWN_CONFIG_STATE",
1: "ENABLED",
2: "DISABLED",
}
var Config_State_value = map[string]int32{
"UNKNOWN_CONFIG_STATE": 0,
"ENABLED": 1,
"DISABLED": 2,
}
var ListConfigsRequest_ListView_name = map[int32]string{
0: "BASIC",
1: "FULL",
}
var ListConfigsRequest_ListView_value = map[string]int32{
"BASIC": 0,
"FULL": 1,
}
Functions ¶
func RegisterQuotaHandler ¶
RegisterQuotaHandler registers the http handlers for service Quota to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterQuotaHandlerFromEndpoint ¶
func RegisterQuotaHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterQuotaHandlerFromEndpoint is same as RegisterQuotaHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterQuotaServer ¶
func RegisterQuotaServer(s *grpc.Server, srv QuotaServer)
Types ¶
type Config ¶
type Config struct { // Name of the config, eg, “quotas/trees/1234/read/config”. // Readonly. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // State of the config. State Config_State `protobuf:"varint,2,opt,name=state,enum=quotapb.Config_State" json:"state,omitempty"` // Max number of tokens available for the config. MaxTokens int64 `protobuf:"varint,3,opt,name=max_tokens,json=maxTokens" json:"max_tokens,omitempty"` // Replenishment strategy used by the config. // // Types that are valid to be assigned to ReplenishmentStrategy: // *Config_SequencingBased // *Config_TimeBased ReplenishmentStrategy isConfig_ReplenishmentStrategy `protobuf_oneof:"replenishment_strategy"` // Current number of tokens available for the config. // May be higher than max_tokens for DISABLED configs, which are considered to // have "infinite" tokens. // Readonly. CurrentTokens int64 `protobuf:"varint,6,opt,name=current_tokens,json=currentTokens" json:"current_tokens,omitempty"` }
Configuration of a quota.
Quotas contain a certain number of tokens that get applied to their corresponding entities. Global quotas apply to all operations, tree and user quotas to certain trees and users, respectively.
Performing an operation costs a certain number of tokens (usually one). Once a quota has no more tokens available, requests that would subtract from it are denied with a resource_exhausted error.
Tokens may be replenished in two different ways: either by passage of time or sequencing progress. Time-based replenishment adds a fixed amount of tokens after a certain interval. Sequencing-based adds a token for each leaf processed by the sequencer. Sequencing-based replenishment may only be used with global and tree quotas.
A quota may be disabled or removed at any time. The effect is the same: a disabled or non-existing quota is considered infinite by the quota system. (Disabling is handy if you plan to re-enable a quota later on.)
func (*Config) Descriptor ¶
func (*Config) GetCurrentTokens ¶
func (*Config) GetMaxTokens ¶
func (*Config) GetReplenishmentStrategy ¶
func (m *Config) GetReplenishmentStrategy() isConfig_ReplenishmentStrategy
func (*Config) GetSequencingBased ¶
func (m *Config) GetSequencingBased() *SequencingBasedStrategy
func (*Config) GetState ¶
func (m *Config) GetState() Config_State
func (*Config) GetTimeBased ¶
func (m *Config) GetTimeBased() *TimeBasedStrategy
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
type Config_SequencingBased ¶
type Config_SequencingBased struct {
SequencingBased *SequencingBasedStrategy `protobuf:"bytes,4,opt,name=sequencing_based,json=sequencingBased,oneof"`
}
type Config_State ¶
type Config_State int32
Possible states of a quota configuration.
const ( // Unknown quota state. Invalid. Config_UNKNOWN_CONFIG_STATE Config_State = 0 // Quota is enabled. Config_ENABLED Config_State = 1 // Quota is disabled (considered infinite). Config_DISABLED Config_State = 2 )
func (Config_State) EnumDescriptor ¶
func (Config_State) EnumDescriptor() ([]byte, []int)
func (Config_State) String ¶
func (x Config_State) String() string
type Config_TimeBased ¶
type Config_TimeBased struct {
TimeBased *TimeBasedStrategy `protobuf:"bytes,5,opt,name=time_based,json=timeBased,oneof"`
}
type CreateConfigRequest ¶
type CreateConfigRequest struct { // Name of the config to create. // For example, "quotas/global/read/config" (global/read quota) or // "quotas/trees/1234/write/config" (write quota for tree 1234). Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // Config to be created. Config *Config `protobuf:"bytes,2,opt,name=config" json:"config,omitempty"` }
CreateConfig request.
func (*CreateConfigRequest) Descriptor ¶
func (*CreateConfigRequest) Descriptor() ([]byte, []int)
func (*CreateConfigRequest) GetConfig ¶
func (m *CreateConfigRequest) GetConfig() *Config
func (*CreateConfigRequest) GetName ¶
func (m *CreateConfigRequest) GetName() string
func (*CreateConfigRequest) ProtoMessage ¶
func (*CreateConfigRequest) ProtoMessage()
func (*CreateConfigRequest) Reset ¶
func (m *CreateConfigRequest) Reset()
func (*CreateConfigRequest) String ¶
func (m *CreateConfigRequest) String() string
type DeleteConfigRequest ¶
type DeleteConfigRequest struct { // Name of the config to delete. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` }
DeleteConfig request.
func (*DeleteConfigRequest) Descriptor ¶
func (*DeleteConfigRequest) Descriptor() ([]byte, []int)
func (*DeleteConfigRequest) GetName ¶
func (m *DeleteConfigRequest) GetName() string
func (*DeleteConfigRequest) ProtoMessage ¶
func (*DeleteConfigRequest) ProtoMessage()
func (*DeleteConfigRequest) Reset ¶
func (m *DeleteConfigRequest) Reset()
func (*DeleteConfigRequest) String ¶
func (m *DeleteConfigRequest) String() string
type GetConfigRequest ¶
type GetConfigRequest struct { // Name of the config to retrieve. // For example, "quotas/global/read/config". Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` }
GetConfig request.
func (*GetConfigRequest) Descriptor ¶
func (*GetConfigRequest) Descriptor() ([]byte, []int)
func (*GetConfigRequest) GetName ¶
func (m *GetConfigRequest) GetName() string
func (*GetConfigRequest) ProtoMessage ¶
func (*GetConfigRequest) ProtoMessage()
func (*GetConfigRequest) Reset ¶
func (m *GetConfigRequest) Reset()
func (*GetConfigRequest) String ¶
func (m *GetConfigRequest) String() string
type ListConfigsRequest ¶
type ListConfigsRequest struct { // Names of the config to retrieve. For example, "quotas/global/read/config". // If empty, all configs are listed. // Name components may be substituted by "-" to search for all variations of // that component. For example: // - "quotas/global/-/config" (both read and write global quotas) // - "quotas/trees/-/-/config" (all tree quotas) Names []string `protobuf:"bytes,1,rep,name=names" json:"names,omitempty"` // View specifies how much data to return. View ListConfigsRequest_ListView `protobuf:"varint,2,opt,name=view,enum=quotapb.ListConfigsRequest_ListView" json:"view,omitempty"` }
ListConfig request.
func (*ListConfigsRequest) Descriptor ¶
func (*ListConfigsRequest) Descriptor() ([]byte, []int)
func (*ListConfigsRequest) GetNames ¶
func (m *ListConfigsRequest) GetNames() []string
func (*ListConfigsRequest) GetView ¶
func (m *ListConfigsRequest) GetView() ListConfigsRequest_ListView
func (*ListConfigsRequest) ProtoMessage ¶
func (*ListConfigsRequest) ProtoMessage()
func (*ListConfigsRequest) Reset ¶
func (m *ListConfigsRequest) Reset()
func (*ListConfigsRequest) String ¶
func (m *ListConfigsRequest) String() string
type ListConfigsRequest_ListView ¶
type ListConfigsRequest_ListView int32
Possible views for ListConfig.
const ( // Only the Config name gets returned. ListConfigsRequest_BASIC ListConfigsRequest_ListView = 0 // Complete Config. ListConfigsRequest_FULL ListConfigsRequest_ListView = 1 )
func (ListConfigsRequest_ListView) EnumDescriptor ¶
func (ListConfigsRequest_ListView) EnumDescriptor() ([]byte, []int)
func (ListConfigsRequest_ListView) String ¶
func (x ListConfigsRequest_ListView) String() string
type ListConfigsResponse ¶
type ListConfigsResponse struct { // Configs matching the request filter. Configs []*Config `protobuf:"bytes,1,rep,name=configs" json:"configs,omitempty"` }
ListConfig response.
func (*ListConfigsResponse) Descriptor ¶
func (*ListConfigsResponse) Descriptor() ([]byte, []int)
func (*ListConfigsResponse) GetConfigs ¶
func (m *ListConfigsResponse) GetConfigs() []*Config
func (*ListConfigsResponse) ProtoMessage ¶
func (*ListConfigsResponse) ProtoMessage()
func (*ListConfigsResponse) Reset ¶
func (m *ListConfigsResponse) Reset()
func (*ListConfigsResponse) String ¶
func (m *ListConfigsResponse) String() string
type QuotaClient ¶
type QuotaClient interface { // Creates a new quota. CreateConfig(ctx context.Context, in *CreateConfigRequest, opts ...grpc.CallOption) (*Config, error) // Deletes an existing quota. Non-existing quotas are considered infinite by // the quota system. DeleteConfig(ctx context.Context, in *DeleteConfigRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) // Retrieves a quota by name. GetConfig(ctx context.Context, in *GetConfigRequest, opts ...grpc.CallOption) (*Config, error) // Lists quotas according to the specified criteria. ListConfigs(ctx context.Context, in *ListConfigsRequest, opts ...grpc.CallOption) (*ListConfigsResponse, error) // Updates a quota. UpdateConfig(ctx context.Context, in *UpdateConfigRequest, opts ...grpc.CallOption) (*Config, error) }
func NewQuotaClient ¶
func NewQuotaClient(cc *grpc.ClientConn) QuotaClient
type QuotaServer ¶
type QuotaServer interface { // Creates a new quota. CreateConfig(context.Context, *CreateConfigRequest) (*Config, error) // Deletes an existing quota. Non-existing quotas are considered infinite by // the quota system. DeleteConfig(context.Context, *DeleteConfigRequest) (*google_protobuf1.Empty, error) // Retrieves a quota by name. GetConfig(context.Context, *GetConfigRequest) (*Config, error) // Lists quotas according to the specified criteria. ListConfigs(context.Context, *ListConfigsRequest) (*ListConfigsResponse, error) // Updates a quota. UpdateConfig(context.Context, *UpdateConfigRequest) (*Config, error) }
type SequencingBasedStrategy ¶
type SequencingBasedStrategy struct { }
Sequencing-based replenishment strategy settings.
Only global/write and trees/write quotas may use sequencing-based replenishment.
func (*SequencingBasedStrategy) Descriptor ¶
func (*SequencingBasedStrategy) Descriptor() ([]byte, []int)
func (*SequencingBasedStrategy) ProtoMessage ¶
func (*SequencingBasedStrategy) ProtoMessage()
func (*SequencingBasedStrategy) Reset ¶
func (m *SequencingBasedStrategy) Reset()
func (*SequencingBasedStrategy) String ¶
func (m *SequencingBasedStrategy) String() string
type TimeBasedStrategy ¶
type TimeBasedStrategy struct { // Number of tokens to replenish at every replenish_interval_seconds. TokensToReplenish int64 `protobuf:"varint,1,opt,name=tokens_to_replenish,json=tokensToReplenish" json:"tokens_to_replenish,omitempty"` // Interval at which tokens_to_replenish get replenished. ReplenishIntervalSeconds int64 `` /* 129-byte string literal not displayed */ }
Time-based replenishment strategy settings.
func (*TimeBasedStrategy) Descriptor ¶
func (*TimeBasedStrategy) Descriptor() ([]byte, []int)
func (*TimeBasedStrategy) GetReplenishIntervalSeconds ¶
func (m *TimeBasedStrategy) GetReplenishIntervalSeconds() int64
func (*TimeBasedStrategy) GetTokensToReplenish ¶
func (m *TimeBasedStrategy) GetTokensToReplenish() int64
func (*TimeBasedStrategy) ProtoMessage ¶
func (*TimeBasedStrategy) ProtoMessage()
func (*TimeBasedStrategy) Reset ¶
func (m *TimeBasedStrategy) Reset()
func (*TimeBasedStrategy) String ¶
func (m *TimeBasedStrategy) String() string
type UpdateConfigRequest ¶
type UpdateConfigRequest struct { // Name of the config to update. Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // Config to update. Only the fields specified by update_mask need to be // filled. Config *Config `protobuf:"bytes,2,opt,name=config" json:"config,omitempty"` // Fields modified by the update request. // For example: "state" or "max_tokens". UpdateMask *google_protobuf2.FieldMask `protobuf:"bytes,3,opt,name=update_mask,json=updateMask" json:"update_mask,omitempty"` // If true the updated quota is reset, regardless of the update's contents. // A reset quota is replenished to its maximum number of tokens. ResetQuota bool `protobuf:"varint,4,opt,name=reset_quota,json=resetQuota" json:"reset_quota,omitempty"` }
Updates a quota config according to the update_mask provided.
Some config changes will cause the current number of tokens to be updated, as listed below:
- If max_tokens is reduced and the current number of tokens is greater than the new max_tokens, the current number of tokens is reduced to max_tokens. This happens so the quota is immediately conformant to the new configuration.
- A state transition from disabled to enabled causes the quota to be fully replenished. This happens so the re-enabled quota will enter in action in a known, predictable state.
A "full replenish", also called "reset", may be forced via the reset_quota parameter, regardless of any other changes. For convenience, reset only requests (name and reset_quota = true) are allowed.
func (*UpdateConfigRequest) Descriptor ¶
func (*UpdateConfigRequest) Descriptor() ([]byte, []int)
func (*UpdateConfigRequest) GetConfig ¶
func (m *UpdateConfigRequest) GetConfig() *Config
func (*UpdateConfigRequest) GetName ¶
func (m *UpdateConfigRequest) GetName() string
func (*UpdateConfigRequest) GetResetQuota ¶
func (m *UpdateConfigRequest) GetResetQuota() bool
func (*UpdateConfigRequest) GetUpdateMask ¶
func (m *UpdateConfigRequest) GetUpdateMask() *google_protobuf2.FieldMask
func (*UpdateConfigRequest) ProtoMessage ¶
func (*UpdateConfigRequest) ProtoMessage()
func (*UpdateConfigRequest) Reset ¶
func (m *UpdateConfigRequest) Reset()
func (*UpdateConfigRequest) String ¶
func (m *UpdateConfigRequest) String() string