quotapb

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 22

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.

Index

Constants

View Source
const (
	Quota_CreateConfig_FullMethodName = "/quotapb.Quota/CreateConfig"
	Quota_DeleteConfig_FullMethodName = "/quotapb.Quota/DeleteConfig"
	Quota_GetConfig_FullMethodName    = "/quotapb.Quota/GetConfig"
	Quota_ListConfigs_FullMethodName  = "/quotapb.Quota/ListConfigs"
	Quota_UpdateConfig_FullMethodName = "/quotapb.Quota/UpdateConfig"
)

Variables

View Source
var (
	Config_State_name = map[int32]string{
		0: "UNKNOWN_CONFIG_STATE",
		1: "ENABLED",
		2: "DISABLED",
	}
	Config_State_value = map[string]int32{
		"UNKNOWN_CONFIG_STATE": 0,
		"ENABLED":              1,
		"DISABLED":             2,
	}
)

Enum value maps for Config_State.

View Source
var (
	ListConfigsRequest_ListView_name = map[int32]string{
		0: "BASIC",
		1: "FULL",
	}
	ListConfigsRequest_ListView_value = map[string]int32{
		"BASIC": 0,
		"FULL":  1,
	}
)

Enum value maps for ListConfigsRequest_ListView.

View Source
var File_quotapb_proto protoreflect.FileDescriptor
View Source
var Quota_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "quotapb.Quota",
	HandlerType: (*QuotaServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateConfig",
			Handler:    _Quota_CreateConfig_Handler,
		},
		{
			MethodName: "DeleteConfig",
			Handler:    _Quota_DeleteConfig_Handler,
		},
		{
			MethodName: "GetConfig",
			Handler:    _Quota_GetConfig_Handler,
		},
		{
			MethodName: "ListConfigs",
			Handler:    _Quota_ListConfigs_Handler,
		},
		{
			MethodName: "UpdateConfig",
			Handler:    _Quota_UpdateConfig_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "quotapb.proto",
}

Quota_ServiceDesc is the grpc.ServiceDesc for Quota service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterQuotaServer

func RegisterQuotaServer(s grpc.ServiceRegistrar, 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,proto3" json:"name,omitempty"`
	// State of the config.
	State Config_State `protobuf:"varint,2,opt,name=state,proto3,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,proto3" json:"max_tokens,omitempty"`
	// Replenishment strategy used by the config.
	//
	// Types that are assignable 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,proto3" json:"current_tokens,omitempty"`
	// contains filtered or unexported fields
}

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 deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetCurrentTokens

func (x *Config) GetCurrentTokens() int64

func (*Config) GetMaxTokens

func (x *Config) GetMaxTokens() int64

func (*Config) GetName

func (x *Config) GetName() string

func (*Config) GetReplenishmentStrategy

func (m *Config) GetReplenishmentStrategy() isConfig_ReplenishmentStrategy

func (*Config) GetSequencingBased

func (x *Config) GetSequencingBased() *SequencingBasedStrategy

func (*Config) GetState

func (x *Config) GetState() Config_State

func (*Config) GetTimeBased

func (x *Config) GetTimeBased() *TimeBasedStrategy

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect added in v1.3.9

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type Config_SequencingBased

type Config_SequencingBased struct {
	// Sequencing-based replenishment settings.
	SequencingBased *SequencingBasedStrategy `protobuf:"bytes,4,opt,name=sequencing_based,json=sequencingBased,proto3,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) Descriptor added in v1.3.9

func (Config_State) Enum added in v1.3.9

func (x Config_State) Enum() *Config_State

func (Config_State) EnumDescriptor deprecated

func (Config_State) EnumDescriptor() ([]byte, []int)

Deprecated: Use Config_State.Descriptor instead.

func (Config_State) Number added in v1.3.9

func (Config_State) String

func (x Config_State) String() string

func (Config_State) Type added in v1.3.9

type Config_TimeBased

type Config_TimeBased struct {
	// Time-based replenishment settings.
	TimeBased *TimeBasedStrategy `protobuf:"bytes,5,opt,name=time_based,json=timeBased,proto3,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,proto3" json:"name,omitempty"`
	// Config to be created.
	Config *Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
	// contains filtered or unexported fields
}

CreateConfig request.

func (*CreateConfigRequest) Descriptor deprecated

func (*CreateConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateConfigRequest.ProtoReflect.Descriptor instead.

func (*CreateConfigRequest) GetConfig

func (x *CreateConfigRequest) GetConfig() *Config

func (*CreateConfigRequest) GetName

func (x *CreateConfigRequest) GetName() string

func (*CreateConfigRequest) ProtoMessage

func (*CreateConfigRequest) ProtoMessage()

func (*CreateConfigRequest) ProtoReflect added in v1.3.9

func (x *CreateConfigRequest) ProtoReflect() protoreflect.Message

func (*CreateConfigRequest) Reset

func (x *CreateConfigRequest) Reset()

func (*CreateConfigRequest) String

func (x *CreateConfigRequest) String() string

type DeleteConfigRequest

type DeleteConfigRequest struct {

	// Name of the config to delete.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

DeleteConfig request.

func (*DeleteConfigRequest) Descriptor deprecated

func (*DeleteConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteConfigRequest.ProtoReflect.Descriptor instead.

func (*DeleteConfigRequest) GetName

func (x *DeleteConfigRequest) GetName() string

func (*DeleteConfigRequest) ProtoMessage

func (*DeleteConfigRequest) ProtoMessage()

func (*DeleteConfigRequest) ProtoReflect added in v1.3.9

func (x *DeleteConfigRequest) ProtoReflect() protoreflect.Message

func (*DeleteConfigRequest) Reset

func (x *DeleteConfigRequest) Reset()

func (*DeleteConfigRequest) String

func (x *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,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

GetConfig request.

func (*GetConfigRequest) Descriptor deprecated

func (*GetConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetConfigRequest.ProtoReflect.Descriptor instead.

func (*GetConfigRequest) GetName

func (x *GetConfigRequest) GetName() string

func (*GetConfigRequest) ProtoMessage

func (*GetConfigRequest) ProtoMessage()

func (*GetConfigRequest) ProtoReflect added in v1.3.9

func (x *GetConfigRequest) ProtoReflect() protoreflect.Message

func (*GetConfigRequest) Reset

func (x *GetConfigRequest) Reset()

func (*GetConfigRequest) String

func (x *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,proto3" json:"names,omitempty"`
	// View specifies how much data to return.
	View ListConfigsRequest_ListView `protobuf:"varint,2,opt,name=view,proto3,enum=quotapb.ListConfigsRequest_ListView" json:"view,omitempty"`
	// contains filtered or unexported fields
}

ListConfig request.

func (*ListConfigsRequest) Descriptor deprecated

func (*ListConfigsRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListConfigsRequest.ProtoReflect.Descriptor instead.

func (*ListConfigsRequest) GetNames

func (x *ListConfigsRequest) GetNames() []string

func (*ListConfigsRequest) GetView

func (*ListConfigsRequest) ProtoMessage

func (*ListConfigsRequest) ProtoMessage()

func (*ListConfigsRequest) ProtoReflect added in v1.3.9

func (x *ListConfigsRequest) ProtoReflect() protoreflect.Message

func (*ListConfigsRequest) Reset

func (x *ListConfigsRequest) Reset()

func (*ListConfigsRequest) String

func (x *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) Descriptor added in v1.3.9

func (ListConfigsRequest_ListView) Enum added in v1.3.9

func (ListConfigsRequest_ListView) EnumDescriptor deprecated

func (ListConfigsRequest_ListView) EnumDescriptor() ([]byte, []int)

Deprecated: Use ListConfigsRequest_ListView.Descriptor instead.

func (ListConfigsRequest_ListView) Number added in v1.3.9

func (ListConfigsRequest_ListView) String

func (ListConfigsRequest_ListView) Type added in v1.3.9

type ListConfigsResponse

type ListConfigsResponse struct {

	// Configs matching the request filter.
	Configs []*Config `protobuf:"bytes,1,rep,name=configs,proto3" json:"configs,omitempty"`
	// contains filtered or unexported fields
}

ListConfig response.

func (*ListConfigsResponse) Descriptor deprecated

func (*ListConfigsResponse) Descriptor() ([]byte, []int)

Deprecated: Use ListConfigsResponse.ProtoReflect.Descriptor instead.

func (*ListConfigsResponse) GetConfigs

func (x *ListConfigsResponse) GetConfigs() []*Config

func (*ListConfigsResponse) ProtoMessage

func (*ListConfigsResponse) ProtoMessage()

func (*ListConfigsResponse) ProtoReflect added in v1.3.9

func (x *ListConfigsResponse) ProtoReflect() protoreflect.Message

func (*ListConfigsResponse) Reset

func (x *ListConfigsResponse) Reset()

func (*ListConfigsResponse) String

func (x *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) (*emptypb.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)
}

QuotaClient is the client API for Quota service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

Quota administrative interface.

Allows creation and management of quotas.

func NewQuotaClient

func NewQuotaClient(cc grpc.ClientConnInterface) 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) (*emptypb.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)
}

QuotaServer is the server API for Quota service. All implementations should embed UnimplementedQuotaServer for forward compatibility.

Quota administrative interface.

Allows creation and management of quotas.

type SequencingBasedStrategy

type SequencingBasedStrategy struct {
	// contains filtered or unexported fields
}

Sequencing-based replenishment strategy settings.

Only global/write and trees/write quotas may use sequencing-based replenishment.

func (*SequencingBasedStrategy) Descriptor deprecated

func (*SequencingBasedStrategy) Descriptor() ([]byte, []int)

Deprecated: Use SequencingBasedStrategy.ProtoReflect.Descriptor instead.

func (*SequencingBasedStrategy) ProtoMessage

func (*SequencingBasedStrategy) ProtoMessage()

func (*SequencingBasedStrategy) ProtoReflect added in v1.3.9

func (x *SequencingBasedStrategy) ProtoReflect() protoreflect.Message

func (*SequencingBasedStrategy) Reset

func (x *SequencingBasedStrategy) Reset()

func (*SequencingBasedStrategy) String

func (x *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,proto3" json:"tokens_to_replenish,omitempty"`
	// Interval at which tokens_to_replenish get replenished.
	ReplenishIntervalSeconds int64 `` /* 136-byte string literal not displayed */
	// contains filtered or unexported fields
}

Time-based replenishment strategy settings.

func (*TimeBasedStrategy) Descriptor deprecated

func (*TimeBasedStrategy) Descriptor() ([]byte, []int)

Deprecated: Use TimeBasedStrategy.ProtoReflect.Descriptor instead.

func (*TimeBasedStrategy) GetReplenishIntervalSeconds

func (x *TimeBasedStrategy) GetReplenishIntervalSeconds() int64

func (*TimeBasedStrategy) GetTokensToReplenish

func (x *TimeBasedStrategy) GetTokensToReplenish() int64

func (*TimeBasedStrategy) ProtoMessage

func (*TimeBasedStrategy) ProtoMessage()

func (*TimeBasedStrategy) ProtoReflect added in v1.3.9

func (x *TimeBasedStrategy) ProtoReflect() protoreflect.Message

func (*TimeBasedStrategy) Reset

func (x *TimeBasedStrategy) Reset()

func (*TimeBasedStrategy) String

func (x *TimeBasedStrategy) String() string

type UnimplementedQuotaServer added in v1.3.0

type UnimplementedQuotaServer struct{}

UnimplementedQuotaServer should be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedQuotaServer) CreateConfig added in v1.3.0

func (UnimplementedQuotaServer) DeleteConfig added in v1.3.0

func (UnimplementedQuotaServer) GetConfig added in v1.3.0

func (UnimplementedQuotaServer) ListConfigs added in v1.3.0

func (UnimplementedQuotaServer) UpdateConfig added in v1.3.0

type UnsafeQuotaServer added in v1.4.0

type UnsafeQuotaServer interface {
	// contains filtered or unexported methods
}

UnsafeQuotaServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to QuotaServer will result in compilation errors.

type UpdateConfigRequest

type UpdateConfigRequest struct {

	// Name of the config to update.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" 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,proto3" json:"config,omitempty"`
	// Fields modified by the update request.
	// For example: "state" or "max_tokens".
	UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,3,opt,name=update_mask,json=updateMask,proto3" 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,proto3" json:"reset_quota,omitempty"`
	// contains filtered or unexported fields
}

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 deprecated

func (*UpdateConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateConfigRequest.ProtoReflect.Descriptor instead.

func (*UpdateConfigRequest) GetConfig

func (x *UpdateConfigRequest) GetConfig() *Config

func (*UpdateConfigRequest) GetName

func (x *UpdateConfigRequest) GetName() string

func (*UpdateConfigRequest) GetResetQuota

func (x *UpdateConfigRequest) GetResetQuota() bool

func (*UpdateConfigRequest) GetUpdateMask

func (x *UpdateConfigRequest) GetUpdateMask() *fieldmaskpb.FieldMask

func (*UpdateConfigRequest) ProtoMessage

func (*UpdateConfigRequest) ProtoMessage()

func (*UpdateConfigRequest) ProtoReflect added in v1.3.9

func (x *UpdateConfigRequest) ProtoReflect() protoreflect.Message

func (*UpdateConfigRequest) Reset

func (x *UpdateConfigRequest) Reset()

func (*UpdateConfigRequest) String

func (x *UpdateConfigRequest) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL