ratelimit

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RateLimitResponse_Code_name = map[int32]string{
	0: "UNKNOWN",
	1: "OK",
	2: "OVER_LIMIT",
}
View Source
var RateLimitResponse_Code_value = map[string]int32{
	"UNKNOWN":    0,
	"OK":         1,
	"OVER_LIMIT": 2,
}
View Source
var RateLimit_Unit_name = map[int32]string{
	0: "UNKNOWN",
	1: "SECOND",
	2: "MINUTE",
	3: "HOUR",
	4: "DAY",
}
View Source
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,proto3" json:"requests_per_unit,omitempty"`
	Unit                 RateLimit_Unit `protobuf:"varint,2,opt,name=unit,proto3,enum=pb.lyft.ratelimit.RateLimit_Unit" json:"unit,omitempty"`
	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
	XXX_unrecognized     []byte         `json:"-"`
	XXX_sizecache        int32          `json:"-"`
}

Defines an actual rate limit in terms of requests per unit of time and the unit itself.

func (*RateLimit) Descriptor

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

func (*RateLimit) GetRequestsPerUnit

func (m *RateLimit) GetRequestsPerUnit() uint32

func (*RateLimit) GetUnit

func (m *RateLimit) GetUnit() RateLimit_Unit

func (*RateLimit) ProtoMessage

func (*RateLimit) ProtoMessage()

func (*RateLimit) Reset

func (m *RateLimit) Reset()

func (*RateLimit) String

func (m *RateLimit) String() string

func (*RateLimit) XXX_DiscardUnknown added in v1.3.0

func (m *RateLimit) XXX_DiscardUnknown()

func (*RateLimit) XXX_Marshal added in v1.3.0

func (m *RateLimit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RateLimit) XXX_Merge added in v1.3.0

func (dst *RateLimit) XXX_Merge(src proto.Message)

func (*RateLimit) XXX_Size added in v1.3.0

func (m *RateLimit) XXX_Size() int

func (*RateLimit) XXX_Unmarshal added in v1.3.0

func (m *RateLimit) XXX_Unmarshal(b []byte) error

type RateLimitDescriptor

type RateLimitDescriptor struct {
	Entries              []*RateLimitDescriptor_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                     `json:"-"`
	XXX_unrecognized     []byte                       `json:"-"`
	XXX_sizecache        int32                        `json:"-"`
}

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".

  1. ["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.
  2. ["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).
  3. ["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.
  4. ["authenticated": "true"], ["client_id": "foo"] What it does: Limits all traffic for an authenticated client "foo"
  5. ["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 (*RateLimitDescriptor) ProtoMessage

func (*RateLimitDescriptor) ProtoMessage()

func (*RateLimitDescriptor) Reset

func (m *RateLimitDescriptor) Reset()

func (*RateLimitDescriptor) String

func (m *RateLimitDescriptor) String() string

func (*RateLimitDescriptor) XXX_DiscardUnknown added in v1.3.0

func (m *RateLimitDescriptor) XXX_DiscardUnknown()

func (*RateLimitDescriptor) XXX_Marshal added in v1.3.0

func (m *RateLimitDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RateLimitDescriptor) XXX_Merge added in v1.3.0

func (dst *RateLimitDescriptor) XXX_Merge(src proto.Message)

func (*RateLimitDescriptor) XXX_Size added in v1.3.0

func (m *RateLimitDescriptor) XXX_Size() int

func (*RateLimitDescriptor) XXX_Unmarshal added in v1.3.0

func (m *RateLimitDescriptor) XXX_Unmarshal(b []byte) error

type RateLimitDescriptor_Entry

type RateLimitDescriptor_Entry struct {
	Key                  string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value                string   `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

func (*RateLimitDescriptor_Entry) XXX_DiscardUnknown added in v1.3.0

func (m *RateLimitDescriptor_Entry) XXX_DiscardUnknown()

func (*RateLimitDescriptor_Entry) XXX_Marshal added in v1.3.0

func (m *RateLimitDescriptor_Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RateLimitDescriptor_Entry) XXX_Merge added in v1.3.0

func (dst *RateLimitDescriptor_Entry) XXX_Merge(src proto.Message)

func (*RateLimitDescriptor_Entry) XXX_Size added in v1.3.0

func (m *RateLimitDescriptor_Entry) XXX_Size() int

func (*RateLimitDescriptor_Entry) XXX_Unmarshal added in v1.3.0

func (m *RateLimitDescriptor_Entry) XXX_Unmarshal(b []byte) error

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,proto3" 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,proto3" 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,proto3" json:"hits_addend,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

func (*RateLimitRequest) XXX_DiscardUnknown added in v1.3.0

func (m *RateLimitRequest) XXX_DiscardUnknown()

func (*RateLimitRequest) XXX_Marshal added in v1.3.0

func (m *RateLimitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RateLimitRequest) XXX_Merge added in v1.3.0

func (dst *RateLimitRequest) XXX_Merge(src proto.Message)

func (*RateLimitRequest) XXX_Size added in v1.3.0

func (m *RateLimitRequest) XXX_Size() int

func (*RateLimitRequest) XXX_Unmarshal added in v1.3.0

func (m *RateLimitRequest) XXX_Unmarshal(b []byte) error

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 `` /* 141-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,proto3" json:"statuses,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                              `json:"-"`
	XXX_unrecognized     []byte                                `json:"-"`
	XXX_sizecache        int32                                 `json:"-"`
}

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 (*RateLimitResponse) ProtoMessage

func (*RateLimitResponse) ProtoMessage()

func (*RateLimitResponse) Reset

func (m *RateLimitResponse) Reset()

func (*RateLimitResponse) String

func (m *RateLimitResponse) String() string

func (*RateLimitResponse) XXX_DiscardUnknown added in v1.3.0

func (m *RateLimitResponse) XXX_DiscardUnknown()

func (*RateLimitResponse) XXX_Marshal added in v1.3.0

func (m *RateLimitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RateLimitResponse) XXX_Merge added in v1.3.0

func (dst *RateLimitResponse) XXX_Merge(src proto.Message)

func (*RateLimitResponse) XXX_Size added in v1.3.0

func (m *RateLimitResponse) XXX_Size() int

func (*RateLimitResponse) XXX_Unmarshal added in v1.3.0

func (m *RateLimitResponse) XXX_Unmarshal(b []byte) error

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,proto3,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,proto3" json:"current_limit,omitempty"`
	// The limit remaining in the current time unit.
	LimitRemaining       uint32   `protobuf:"varint,3,opt,name=limit_remaining,json=limitRemaining,proto3" json:"limit_remaining,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RateLimitResponse_DescriptorStatus) Descriptor

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

func (*RateLimitResponse_DescriptorStatus) GetCode

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 (*RateLimitResponse_DescriptorStatus) String

func (*RateLimitResponse_DescriptorStatus) XXX_DiscardUnknown added in v1.3.0

func (m *RateLimitResponse_DescriptorStatus) XXX_DiscardUnknown()

func (*RateLimitResponse_DescriptorStatus) XXX_Marshal added in v1.3.0

func (m *RateLimitResponse_DescriptorStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RateLimitResponse_DescriptorStatus) XXX_Merge added in v1.3.0

func (dst *RateLimitResponse_DescriptorStatus) XXX_Merge(src proto.Message)

func (*RateLimitResponse_DescriptorStatus) XXX_Size added in v1.3.0

func (*RateLimitResponse_DescriptorStatus) XXX_Unmarshal added in v1.3.0

func (m *RateLimitResponse_DescriptorStatus) XXX_Unmarshal(b []byte) error

type RateLimitServiceClient

type RateLimitServiceClient interface {
	// Determine whether rate limiting should take place.
	ShouldRateLimit(ctx context.Context, in *RateLimitRequest, opts ...grpc.CallOption) (*RateLimitResponse, error)
}

RateLimitServiceClient is the client API for RateLimitService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

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)
}

RateLimitServiceServer is the server API for RateLimitService service.

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

Jump to

Keyboard shortcuts

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