Documentation
¶
Overview ¶
Package quota is a generated protocol buffer package.
It is generated from these files:
github.com/microhq/quota-srv/proto/quota.proto
It has these top-level messages:
AllocateRequest AllocateResponse Config Allocation Update
Package quota is a generated protocol buffer package.
It is generated from these files:
github.com/microhq/quota-srv/proto/quota.proto
It has these top-level messages:
AllocateRequest AllocateResponse Config Allocation Update
Index ¶
- Variables
- func RegisterQuotaHandler(s server.Server, hdlr QuotaHandler, opts ...server.HandlerOption) error
- type AllocateRequest
- func (*AllocateRequest) Descriptor() ([]byte, []int)
- func (m *AllocateRequest) GetAllocation() int64
- func (m *AllocateRequest) GetBucket() string
- func (m *AllocateRequest) GetResource() string
- func (*AllocateRequest) ProtoMessage()
- func (m *AllocateRequest) Reset()
- func (m *AllocateRequest) String() string
- type AllocateResponse
- type AllocateResponse_Status
- type Allocation
- func (*Allocation) Descriptor() ([]byte, []int)
- func (m *Allocation) GetBucket() string
- func (m *Allocation) GetResource() string
- func (m *Allocation) GetTimestamp() int64
- func (m *Allocation) GetTotal() int64
- func (*Allocation) ProtoMessage()
- func (m *Allocation) Reset()
- func (m *Allocation) String() string
- type Config
- type QuotaHandler
- type QuotaService
- type Update
Constants ¶
This section is empty.
Variables ¶
View Source
var AllocateResponse_Status_name = map[int32]string{
0: "OK",
1: "REJECT_TOO_MANY_REQUESTS",
2: "REJECT_SERVER_ERROR",
}
View Source
var AllocateResponse_Status_value = map[string]int32{
"OK": 0,
"REJECT_TOO_MANY_REQUESTS": 1,
"REJECT_SERVER_ERROR": 2,
}
Functions ¶
func RegisterQuotaHandler ¶
func RegisterQuotaHandler(s server.Server, hdlr QuotaHandler, opts ...server.HandlerOption) error
Types ¶
type AllocateRequest ¶
type AllocateRequest struct { // name of the resource being used e.g api.maps Resource string `protobuf:"bytes,1,opt,name=resource" json:"resource,omitempty"` // shared bucket for the client e.g ip address, service name Bucket string `protobuf:"bytes,2,opt,name=bucket" json:"bucket,omitempty"` // resource allocation e.g 10 requests Allocation int64 `protobuf:"varint,3,opt,name=allocation" json:"allocation,omitempty"` }
func (*AllocateRequest) Descriptor ¶
func (*AllocateRequest) Descriptor() ([]byte, []int)
func (*AllocateRequest) GetAllocation ¶
func (m *AllocateRequest) GetAllocation() int64
func (*AllocateRequest) GetBucket ¶
func (m *AllocateRequest) GetBucket() string
func (*AllocateRequest) GetResource ¶
func (m *AllocateRequest) GetResource() string
func (*AllocateRequest) ProtoMessage ¶
func (*AllocateRequest) ProtoMessage()
func (*AllocateRequest) Reset ¶
func (m *AllocateRequest) Reset()
func (*AllocateRequest) String ¶
func (m *AllocateRequest) String() string
type AllocateResponse ¶
type AllocateResponse struct { // status of this allocation Status AllocateResponse_Status `protobuf:"varint,1,opt,name=status,enum=AllocateResponse_Status" json:"status,omitempty"` // resource allocation provided Allocation int64 `protobuf:"varint,2,opt,name=allocation" json:"allocation,omitempty"` }
func (*AllocateResponse) Descriptor ¶
func (*AllocateResponse) Descriptor() ([]byte, []int)
func (*AllocateResponse) GetAllocation ¶
func (m *AllocateResponse) GetAllocation() int64
func (*AllocateResponse) GetStatus ¶
func (m *AllocateResponse) GetStatus() AllocateResponse_Status
func (*AllocateResponse) ProtoMessage ¶
func (*AllocateResponse) ProtoMessage()
func (*AllocateResponse) Reset ¶
func (m *AllocateResponse) Reset()
func (*AllocateResponse) String ¶
func (m *AllocateResponse) String() string
type AllocateResponse_Status ¶
type AllocateResponse_Status int32
const ( AllocateResponse_OK AllocateResponse_Status = 0 AllocateResponse_REJECT_TOO_MANY_REQUESTS AllocateResponse_Status = 1 AllocateResponse_REJECT_SERVER_ERROR AllocateResponse_Status = 2 )
func (AllocateResponse_Status) EnumDescriptor ¶
func (AllocateResponse_Status) EnumDescriptor() ([]byte, []int)
func (AllocateResponse_Status) String ¶
func (x AllocateResponse_Status) String() string
type Allocation ¶
type Allocation struct { // name of the resource being used e.g api.maps Resource string `protobuf:"bytes,1,opt,name=resource" json:"resource,omitempty"` // shared bucket for the client e.g ip address, service name Bucket string `protobuf:"bytes,2,opt,name=bucket" json:"bucket,omitempty"` // total used e.g 10 requests Total int64 `protobuf:"varint,3,opt,name=total" json:"total,omitempty"` // time at which the allocation occurred. unix timestamp Timestamp int64 `protobuf:"varint,4,opt,name=timestamp" json:"timestamp,omitempty"` }
func (*Allocation) Descriptor ¶
func (*Allocation) Descriptor() ([]byte, []int)
func (*Allocation) GetBucket ¶
func (m *Allocation) GetBucket() string
func (*Allocation) GetResource ¶
func (m *Allocation) GetResource() string
func (*Allocation) GetTimestamp ¶
func (m *Allocation) GetTimestamp() int64
func (*Allocation) GetTotal ¶
func (m *Allocation) GetTotal() int64
func (*Allocation) ProtoMessage ¶
func (*Allocation) ProtoMessage()
func (*Allocation) Reset ¶
func (m *Allocation) Reset()
func (*Allocation) String ¶
func (m *Allocation) String() string
type Config ¶
type Config struct { // window over which to manage quota WindowSize int64 `protobuf:"varint,1,opt,name=window_size,json=windowSize" json:"window_size,omitempty"` // per second rate limit RateLimit int64 `protobuf:"varint,2,opt,name=rate_limit,json=rateLimit" json:"rate_limit,omitempty"` // total limit over the window TotalLimit int64 `protobuf:"varint,3,opt,name=total_limit,json=totalLimit" json:"total_limit,omitempty"` // ttl after which to expire idle bucket IdleTtl int64 `protobuf:"varint,4,opt,name=idle_ttl,json=idleTtl" json:"idle_ttl,omitempty"` }
Config for the quota manager
func (*Config) Descriptor ¶
func (*Config) GetIdleTtl ¶
func (*Config) GetRateLimit ¶
func (*Config) GetTotalLimit ¶
func (*Config) GetWindowSize ¶
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
type QuotaHandler ¶
type QuotaHandler interface {
Allocate(context.Context, *AllocateRequest, *AllocateResponse) error
}
type QuotaService ¶
type QuotaService interface {
Allocate(ctx context.Context, in *AllocateRequest, opts ...client.CallOption) (*AllocateResponse, error)
}
func NewQuotaService ¶
func NewQuotaService(name string, c client.Client) QuotaService
type Update ¶
type Update struct { // unique id of this update or the sender Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` // time at which it was published Timestamp int64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` // the allocations made Allocations []*Allocation `protobuf:"bytes,3,rep,name=allocations" json:"allocations,omitempty"` }
func (*Update) Descriptor ¶
func (*Update) GetAllocations ¶
func (m *Update) GetAllocations() []*Allocation
func (*Update) GetTimestamp ¶
func (*Update) ProtoMessage ¶
func (*Update) ProtoMessage()
Click to show internal directories.
Click to hide internal directories.