Documentation ¶
Overview ¶
Package ratelimit is a generated protocol buffer package.
It is generated from these files:
proto/ratelimit/ratelimit.proto
It has these top-level messages:
RateLimitRequest RateLimitDescriptor RateLimit RateLimitResponse
Index ¶
- Variables
- func RegisterRateLimitServiceServer(s *grpc.Server, srv RateLimitServiceServer)
- type RateLimit
- type RateLimitDescriptor
- type RateLimitDescriptor_Entry
- func (*RateLimitDescriptor_Entry) Descriptor() ([]byte, []int)
- func (m *RateLimitDescriptor_Entry) GetKey() string
- func (m *RateLimitDescriptor_Entry) GetValue() string
- func (*RateLimitDescriptor_Entry) ProtoMessage()
- func (m *RateLimitDescriptor_Entry) Reset()
- func (m *RateLimitDescriptor_Entry) String() string
- type RateLimitRequest
- func (*RateLimitRequest) Descriptor() ([]byte, []int)
- func (m *RateLimitRequest) GetDescriptors() []*RateLimitDescriptor
- func (m *RateLimitRequest) GetDomain() string
- func (m *RateLimitRequest) GetHitsAddend() uint32
- func (*RateLimitRequest) ProtoMessage()
- func (m *RateLimitRequest) Reset()
- func (m *RateLimitRequest) String() string
- type RateLimitResponse
- func (*RateLimitResponse) Descriptor() ([]byte, []int)
- func (m *RateLimitResponse) GetOverallCode() RateLimitResponse_Code
- func (m *RateLimitResponse) GetStatuses() []*RateLimitResponse_DescriptorStatus
- func (*RateLimitResponse) ProtoMessage()
- func (m *RateLimitResponse) Reset()
- func (m *RateLimitResponse) String() string
- type RateLimitResponse_Code
- type RateLimitResponse_DescriptorStatus
- func (*RateLimitResponse_DescriptorStatus) Descriptor() ([]byte, []int)
- func (m *RateLimitResponse_DescriptorStatus) GetCode() RateLimitResponse_Code
- func (m *RateLimitResponse_DescriptorStatus) GetCurrentLimit() *RateLimit
- func (m *RateLimitResponse_DescriptorStatus) GetLimitRemaining() uint32
- func (*RateLimitResponse_DescriptorStatus) ProtoMessage()
- func (m *RateLimitResponse_DescriptorStatus) Reset()
- func (m *RateLimitResponse_DescriptorStatus) String() string
- type RateLimitServiceClient
- type RateLimitServiceServer
- type RateLimit_Unit
Constants ¶
This section is empty.
Variables ¶
var RateLimitResponse_Code_name = map[int32]string{
0: "UNKNOWN",
1: "OK",
2: "OVER_LIMIT",
}
var RateLimitResponse_Code_value = map[string]int32{
"UNKNOWN": 0,
"OK": 1,
"OVER_LIMIT": 2,
}
var RateLimit_Unit_name = map[int32]string{
0: "UNKNOWN",
1: "SECOND",
2: "MINUTE",
3: "HOUR",
4: "DAY",
}
var RateLimit_Unit_value = map[string]int32{
"UNKNOWN": 0,
"SECOND": 1,
"MINUTE": 2,
"HOUR": 3,
"DAY": 4,
}
Functions ¶
func RegisterRateLimitServiceServer ¶
func RegisterRateLimitServiceServer(s *grpc.Server, srv RateLimitServiceServer)
Types ¶
type RateLimit ¶
type RateLimit struct { RequestsPerUnit uint32 `protobuf:"varint,1,opt,name=requests_per_unit,json=requestsPerUnit" json:"requests_per_unit,omitempty"` Unit RateLimit_Unit `protobuf:"varint,2,opt,name=unit,enum=pb.lyft.ratelimit.RateLimit_Unit" json:"unit,omitempty"` }
Defines an actual rate limit in terms of requests per unit of time and the unit itself.
func (*RateLimit) Descriptor ¶
func (*RateLimit) GetRequestsPerUnit ¶
func (*RateLimit) GetUnit ¶
func (m *RateLimit) GetUnit() RateLimit_Unit
func (*RateLimit) ProtoMessage ¶
func (*RateLimit) ProtoMessage()
type RateLimitDescriptor ¶
type RateLimitDescriptor struct {
Entries []*RateLimitDescriptor_Entry `protobuf:"bytes,1,rep,name=entries" json:"entries,omitempty"`
}
A RateLimitDescriptor is a list of hierarchical entries that are used by the service to determine the final rate limit key and overall allowed limit. Here are some examples of how they might be used for the domain "envoy".
- ["authenticated": "false"], ["ip_address": "10.0.0.1"] What it does: Limits all unauthenticated traffic for the IP address 10.0.0.1. The configuration supplies a default limit for the ip_address field. If there is a desire to raise the limit for 10.0.0.1 or block it entirely it can be specified directly in the configuration.
- ["authenticated": "false"], ["path": "/foo/bar"] What it does: Limits all unauthenticated traffic globally for a specific path (or prefix if configured that way in the service).
- ["authenticated": "false"], ["path": "/foo/bar"], ["ip_address": "10.0.0.1"] What it does: Limits unauthenticated traffic to a specific path for a specific IP address. Like (1) we can raise/block specific IP addresses if we want with an override configuration.
- ["authenticated": "true"], ["client_id": "foo"] What it does: Limits all traffic for an authenticated client "foo"
- ["authenticated": "true"], ["client_id": "foo"], ["path": "/foo/bar"] What it does: Limits traffic to a specific path for an authenticated client "foo"
The idea behind the API is that (1)/(2)/(3) and (4)/(5) can be sent in 1 request if desired. This enables building complex application scenarios with a generic backend.
func (*RateLimitDescriptor) Descriptor ¶
func (*RateLimitDescriptor) Descriptor() ([]byte, []int)
func (*RateLimitDescriptor) GetEntries ¶
func (m *RateLimitDescriptor) GetEntries() []*RateLimitDescriptor_Entry
func (*RateLimitDescriptor) ProtoMessage ¶
func (*RateLimitDescriptor) ProtoMessage()
func (*RateLimitDescriptor) Reset ¶
func (m *RateLimitDescriptor) Reset()
func (*RateLimitDescriptor) String ¶
func (m *RateLimitDescriptor) String() string
type RateLimitDescriptor_Entry ¶
type RateLimitDescriptor_Entry struct { Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` Value string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` }
func (*RateLimitDescriptor_Entry) Descriptor ¶
func (*RateLimitDescriptor_Entry) Descriptor() ([]byte, []int)
func (*RateLimitDescriptor_Entry) GetKey ¶
func (m *RateLimitDescriptor_Entry) GetKey() string
func (*RateLimitDescriptor_Entry) GetValue ¶
func (m *RateLimitDescriptor_Entry) GetValue() string
func (*RateLimitDescriptor_Entry) ProtoMessage ¶
func (*RateLimitDescriptor_Entry) ProtoMessage()
func (*RateLimitDescriptor_Entry) Reset ¶
func (m *RateLimitDescriptor_Entry) Reset()
func (*RateLimitDescriptor_Entry) String ¶
func (m *RateLimitDescriptor_Entry) String() string
type RateLimitRequest ¶
type RateLimitRequest struct { // All rate limit requests must specify a domain. This enables the configuration to be per // application without fear of overlap. E.g., "envoy". Domain string `protobuf:"bytes,1,opt,name=domain" json:"domain,omitempty"` // All rate limit requests must specify at least one RateLimitDescriptor. Each descriptor is // processed by the service (see below). If any of the descriptors are over limit, the entire // request is considered to be over limit. Descriptors []*RateLimitDescriptor `protobuf:"bytes,2,rep,name=descriptors" json:"descriptors,omitempty"` // Rate limit requests can optionally specify the number of hits a request adds to the matched limit. If the // value is not set in the message, a request increases the matched limit by 1. HitsAddend uint32 `protobuf:"varint,3,opt,name=hits_addend,json=hitsAddend" json:"hits_addend,omitempty"` }
Main message for a rate limit request. The rate limit service is designed to be fully generic in the sense that it can operate on arbitrary hierarchical key/value pairs. The loaded configuration will parse the request and find the most specific limit to apply. In addition, a RateLimitRequest can contain multiple "descriptors" to limit on. When multiple descriptors are provided, the server will limit on *ALL* of them and return an OVER_LIMIT response if any of them are over limit. This enables more complex application level rate limiting scenarios if desired.
func (*RateLimitRequest) Descriptor ¶
func (*RateLimitRequest) Descriptor() ([]byte, []int)
func (*RateLimitRequest) GetDescriptors ¶
func (m *RateLimitRequest) GetDescriptors() []*RateLimitDescriptor
func (*RateLimitRequest) GetDomain ¶
func (m *RateLimitRequest) GetDomain() string
func (*RateLimitRequest) GetHitsAddend ¶
func (m *RateLimitRequest) GetHitsAddend() uint32
func (*RateLimitRequest) ProtoMessage ¶
func (*RateLimitRequest) ProtoMessage()
func (*RateLimitRequest) Reset ¶
func (m *RateLimitRequest) Reset()
func (*RateLimitRequest) String ¶
func (m *RateLimitRequest) String() string
type RateLimitResponse ¶
type RateLimitResponse struct { // The overall response code which takes into account all of the descriptors that were passed // in the RateLimitRequest message. OverallCode RateLimitResponse_Code `` /* 134-byte string literal not displayed */ // A list of DescriptorStatus messages which matches the length of the descriptor list passed // in the RateLimitRequest. This can be used by the caller to determine which individual // descriptors failed and/or what the currently configured limits are for all of them. Statuses []*RateLimitResponse_DescriptorStatus `protobuf:"bytes,2,rep,name=statuses" json:"statuses,omitempty"` }
A response from a ShouldRateLimit call.
func (*RateLimitResponse) Descriptor ¶
func (*RateLimitResponse) Descriptor() ([]byte, []int)
func (*RateLimitResponse) GetOverallCode ¶
func (m *RateLimitResponse) GetOverallCode() RateLimitResponse_Code
func (*RateLimitResponse) GetStatuses ¶
func (m *RateLimitResponse) GetStatuses() []*RateLimitResponse_DescriptorStatus
func (*RateLimitResponse) ProtoMessage ¶
func (*RateLimitResponse) ProtoMessage()
func (*RateLimitResponse) Reset ¶
func (m *RateLimitResponse) Reset()
func (*RateLimitResponse) String ¶
func (m *RateLimitResponse) String() string
type RateLimitResponse_Code ¶
type RateLimitResponse_Code int32
const ( RateLimitResponse_UNKNOWN RateLimitResponse_Code = 0 RateLimitResponse_OK RateLimitResponse_Code = 1 RateLimitResponse_OVER_LIMIT RateLimitResponse_Code = 2 )
func (RateLimitResponse_Code) EnumDescriptor ¶
func (RateLimitResponse_Code) EnumDescriptor() ([]byte, []int)
func (RateLimitResponse_Code) String ¶
func (x RateLimitResponse_Code) String() string
type RateLimitResponse_DescriptorStatus ¶
type RateLimitResponse_DescriptorStatus struct { // The response code for an individual descriptor. Code RateLimitResponse_Code `protobuf:"varint,1,opt,name=code,enum=pb.lyft.ratelimit.RateLimitResponse_Code" json:"code,omitempty"` // The current limit as configured by the server. Useful for debugging, etc. CurrentLimit *RateLimit `protobuf:"bytes,2,opt,name=current_limit,json=currentLimit" json:"current_limit,omitempty"` // The limit remaining in the current time unit. LimitRemaining uint32 `protobuf:"varint,3,opt,name=limit_remaining,json=limitRemaining" json:"limit_remaining,omitempty"` }
func (*RateLimitResponse_DescriptorStatus) Descriptor ¶
func (*RateLimitResponse_DescriptorStatus) Descriptor() ([]byte, []int)
func (*RateLimitResponse_DescriptorStatus) GetCode ¶
func (m *RateLimitResponse_DescriptorStatus) GetCode() RateLimitResponse_Code
func (*RateLimitResponse_DescriptorStatus) GetCurrentLimit ¶
func (m *RateLimitResponse_DescriptorStatus) GetCurrentLimit() *RateLimit
func (*RateLimitResponse_DescriptorStatus) GetLimitRemaining ¶
func (m *RateLimitResponse_DescriptorStatus) GetLimitRemaining() uint32
func (*RateLimitResponse_DescriptorStatus) ProtoMessage ¶
func (*RateLimitResponse_DescriptorStatus) ProtoMessage()
func (*RateLimitResponse_DescriptorStatus) Reset ¶
func (m *RateLimitResponse_DescriptorStatus) Reset()
func (*RateLimitResponse_DescriptorStatus) String ¶
func (m *RateLimitResponse_DescriptorStatus) String() string
type RateLimitServiceClient ¶
type RateLimitServiceClient interface { // Determine whether rate limiting should take place. ShouldRateLimit(ctx context.Context, in *RateLimitRequest, opts ...grpc.CallOption) (*RateLimitResponse, error) }
func NewRateLimitServiceClient ¶
func NewRateLimitServiceClient(cc *grpc.ClientConn) RateLimitServiceClient
type RateLimitServiceServer ¶
type RateLimitServiceServer interface { // Determine whether rate limiting should take place. ShouldRateLimit(context.Context, *RateLimitRequest) (*RateLimitResponse, error) }
type RateLimit_Unit ¶
type RateLimit_Unit int32
const ( RateLimit_UNKNOWN RateLimit_Unit = 0 RateLimit_SECOND RateLimit_Unit = 1 RateLimit_MINUTE RateLimit_Unit = 2 RateLimit_HOUR RateLimit_Unit = 3 RateLimit_DAY RateLimit_Unit = 4 )
func (RateLimit_Unit) EnumDescriptor ¶
func (RateLimit_Unit) EnumDescriptor() ([]byte, []int)
func (RateLimit_Unit) String ¶
func (x RateLimit_Unit) String() string