ratelimitv3

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RateLimitService_ShouldRateLimit_FullMethodName = "/envoy.service.ratelimit.v3.RateLimitService/ShouldRateLimit"
)

Variables

View Source
var (
	RateLimitResponse_Code_name = map[int32]string{
		0: "UNKNOWN",
		1: "OK",
		2: "OVER_LIMIT",
	}
	RateLimitResponse_Code_value = map[string]int32{
		"UNKNOWN":    0,
		"OK":         1,
		"OVER_LIMIT": 2,
	}
)

Enum value maps for RateLimitResponse_Code.

View Source
var (
	RateLimitResponse_RateLimit_Unit_name = map[int32]string{
		0: "UNKNOWN",
		1: "SECOND",
		2: "MINUTE",
		3: "HOUR",
		4: "DAY",
		5: "MONTH",
		6: "YEAR",
	}
	RateLimitResponse_RateLimit_Unit_value = map[string]int32{
		"UNKNOWN": 0,
		"SECOND":  1,
		"MINUTE":  2,
		"HOUR":    3,
		"DAY":     4,
		"MONTH":   5,
		"YEAR":    6,
	}
)

Enum value maps for RateLimitResponse_RateLimit_Unit.

View Source
var File_envoy_service_ratelimit_v3_rls_proto protoreflect.FileDescriptor
View Source
var RateLimitService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "envoy.service.ratelimit.v3.RateLimitService",
	HandlerType: (*RateLimitServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ShouldRateLimit",
			Handler:    _RateLimitService_ShouldRateLimit_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "envoy/service/ratelimit/v3/rls.proto",
}

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

Functions

func RegisterRateLimitServiceServer

func RegisterRateLimitServiceServer(s grpc.ServiceRegistrar, srv RateLimitServiceServer)

Types

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 []*v3.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.
	// This value can be overridden by setting filter state value “envoy.ratelimit.hits_addend“
	// to the desired number. Invalid number (< 0) or number will be ignored.
	HitsAddend uint32 `protobuf:"varint,3,opt,name=hits_addend,json=hitsAddend,proto3" json:"hits_addend,omitempty"`
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use RateLimitRequest.ProtoReflect.Descriptor instead.

func (*RateLimitRequest) GetDescriptors

func (x *RateLimitRequest) GetDescriptors() []*v3.RateLimitDescriptor

func (*RateLimitRequest) GetDomain

func (x *RateLimitRequest) GetDomain() string

func (*RateLimitRequest) GetHitsAddend

func (x *RateLimitRequest) GetHitsAddend() uint32

func (*RateLimitRequest) ProtoMessage

func (*RateLimitRequest) ProtoMessage()

func (*RateLimitRequest) ProtoReflect

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

func (*RateLimitRequest) Reset

func (x *RateLimitRequest) Reset()

func (*RateLimitRequest) String

func (x *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 `` /* 150-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"`
	// A list of headers to add to the response
	ResponseHeadersToAdd []*v31.HeaderValue `protobuf:"bytes,3,rep,name=response_headers_to_add,json=responseHeadersToAdd,proto3" json:"response_headers_to_add,omitempty"`
	// A list of headers to add to the request when forwarded
	RequestHeadersToAdd []*v31.HeaderValue `protobuf:"bytes,4,rep,name=request_headers_to_add,json=requestHeadersToAdd,proto3" json:"request_headers_to_add,omitempty"`
	// A response body to send to the downstream client when the response code is not OK.
	RawBody []byte `protobuf:"bytes,5,opt,name=raw_body,json=rawBody,proto3" json:"raw_body,omitempty"`
	// Optional response metadata that will be emitted as dynamic metadata to be consumed by the next
	// filter. This metadata lives in a namespace specified by the canonical name of extension filter
	// that requires it:
	//
	// - :ref:`envoy.filters.http.ratelimit <config_http_filters_ratelimit_dynamic_metadata>` for HTTP filter.
	// - :ref:`envoy.filters.network.ratelimit <config_network_filters_ratelimit_dynamic_metadata>` for network filter.
	// - :ref:`envoy.filters.thrift.rate_limit <config_thrift_filters_rate_limit_dynamic_metadata>` for Thrift filter.
	DynamicMetadata *structpb.Struct `protobuf:"bytes,6,opt,name=dynamic_metadata,json=dynamicMetadata,proto3" json:"dynamic_metadata,omitempty"`
	// Quota is available for a request if its entire descriptor set has cached quota available.
	// This is a union of all descriptors in the descriptor set. Clients can use the quota for future matches if and only if the descriptor set matches what was sent in the request that originated this response.
	//
	// If quota is available, a RLS request will not be made and the quota will be reduced by 1.
	// If quota is not available (i.e., a cached entry doesn't exist for a RLS descriptor set), a RLS request will be triggered.
	// If the server did not provide a quota, such as the quota message is empty then the request admission is determined by the
	// :ref:`overall_code <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.overall_code>`.
	//
	// If there is not sufficient quota and the cached entry exists for a RLS descriptor set is out-of-quota but not expired,
	// the request will be treated as OVER_LIMIT.
	// [#not-implemented-hide:]
	Quota *RateLimitResponse_Quota `protobuf:"bytes,7,opt,name=quota,proto3" json:"quota,omitempty"`
	// contains filtered or unexported fields
}

A response from a ShouldRateLimit call. [#next-free-field: 8]

func (*RateLimitResponse) Descriptor deprecated

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

Deprecated: Use RateLimitResponse.ProtoReflect.Descriptor instead.

func (*RateLimitResponse) GetDynamicMetadata

func (x *RateLimitResponse) GetDynamicMetadata() *structpb.Struct

func (*RateLimitResponse) GetOverallCode

func (x *RateLimitResponse) GetOverallCode() RateLimitResponse_Code

func (*RateLimitResponse) GetQuota

func (*RateLimitResponse) GetRawBody

func (x *RateLimitResponse) GetRawBody() []byte

func (*RateLimitResponse) GetRequestHeadersToAdd

func (x *RateLimitResponse) GetRequestHeadersToAdd() []*v31.HeaderValue

func (*RateLimitResponse) GetResponseHeadersToAdd

func (x *RateLimitResponse) GetResponseHeadersToAdd() []*v31.HeaderValue

func (*RateLimitResponse) GetStatuses

func (*RateLimitResponse) ProtoMessage

func (*RateLimitResponse) ProtoMessage()

func (*RateLimitResponse) ProtoReflect

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

func (*RateLimitResponse) Reset

func (x *RateLimitResponse) Reset()

func (*RateLimitResponse) String

func (x *RateLimitResponse) String() string

type RateLimitResponse_Code

type RateLimitResponse_Code int32
const (
	// The response code is not known.
	RateLimitResponse_UNKNOWN RateLimitResponse_Code = 0
	// The response code to notify that the number of requests are under limit.
	RateLimitResponse_OK RateLimitResponse_Code = 1
	// The response code to notify that the number of requests are over limit.
	RateLimitResponse_OVER_LIMIT RateLimitResponse_Code = 2
)

func (RateLimitResponse_Code) Descriptor

func (RateLimitResponse_Code) Enum

func (RateLimitResponse_Code) EnumDescriptor deprecated

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

Deprecated: Use RateLimitResponse_Code.Descriptor instead.

func (RateLimitResponse_Code) Number

func (RateLimitResponse_Code) String

func (x RateLimitResponse_Code) String() string

func (RateLimitResponse_Code) Type

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=envoy.service.ratelimit.v3.RateLimitResponse_Code" json:"code,omitempty"`
	// The current limit as configured by the server. Useful for debugging, etc.
	CurrentLimit *RateLimitResponse_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"`
	// Duration until reset of the current limit window.
	DurationUntilReset *durationpb.Duration `protobuf:"bytes,4,opt,name=duration_until_reset,json=durationUntilReset,proto3" json:"duration_until_reset,omitempty"`
	// Quota is available for a request if its descriptor set has cached quota available for all
	// descriptors.
	// This is for each individual descriptor in the descriptor set. The client will perform matches for each individual descriptor against available per-descriptor quota.
	//
	// If quota is available, a RLS request will not be made and the quota will be reduced by 1 for
	// all matching descriptors.
	//
	// If there is not sufficient quota, there are three cases:
	//  1. A cached entry exists for a RLS descriptor that is out-of-quota, but not expired.
	//     In this case, the request will be treated as OVER_LIMIT.
	//  2. Some RLS descriptors have a cached entry that has valid quota but some RLS descriptors
	//     have no cached entry. This will trigger a new RLS request.
	//     When the result is returned, a single unit will be consumed from the quota for all
	//     matching descriptors.
	//     If the server did not provide a quota, such as the quota message is empty for some of
	//     the descriptors, then the request admission is determined by the
	//     :ref:`overall_code <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.overall_code>`.
	//  3. All RLS descriptors lack a cached entry, this will trigger a new RLS request,
	//     When the result is returned, a single unit will be consumed from the quota for all
	//     matching descriptors.
	//     If the server did not provide a quota, such as the quota message is empty for some of
	//     the descriptors, then the request admission is determined by the
	//     :ref:`overall_code <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.overall_code>`.
	//
	// [#not-implemented-hide:]
	Quota *RateLimitResponse_Quota `protobuf:"bytes,5,opt,name=quota,proto3" json:"quota,omitempty"`
	// contains filtered or unexported fields
}

[#next-free-field: 6]

func (*RateLimitResponse_DescriptorStatus) Descriptor deprecated

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

Deprecated: Use RateLimitResponse_DescriptorStatus.ProtoReflect.Descriptor instead.

func (*RateLimitResponse_DescriptorStatus) GetCode

func (*RateLimitResponse_DescriptorStatus) GetCurrentLimit

func (*RateLimitResponse_DescriptorStatus) GetDurationUntilReset

func (x *RateLimitResponse_DescriptorStatus) GetDurationUntilReset() *durationpb.Duration

func (*RateLimitResponse_DescriptorStatus) GetLimitRemaining

func (x *RateLimitResponse_DescriptorStatus) GetLimitRemaining() uint32

func (*RateLimitResponse_DescriptorStatus) GetQuota

func (*RateLimitResponse_DescriptorStatus) ProtoMessage

func (*RateLimitResponse_DescriptorStatus) ProtoMessage()

func (*RateLimitResponse_DescriptorStatus) ProtoReflect

func (*RateLimitResponse_DescriptorStatus) Reset

func (*RateLimitResponse_DescriptorStatus) String

type RateLimitResponse_Quota

type RateLimitResponse_Quota struct {

	// Number of matching requests granted in quota. Must be 1 or more.
	Requests uint32 `protobuf:"varint,1,opt,name=requests,proto3" json:"requests,omitempty"`
	// Types that are assignable to ExpirationSpecifier:
	//
	//	*RateLimitResponse_Quota_ValidUntil
	ExpirationSpecifier isRateLimitResponse_Quota_ExpirationSpecifier `protobuf_oneof:"expiration_specifier"`
	// The unique id that is associated with each Quota either at individual descriptor level or whole descriptor set level.
	//
	// For a matching policy with boolean logic, for example, match: "request.headers['environment'] == 'staging' || request.headers['environment'] == 'dev'"),
	// the request_headers action produces a distinct list of descriptors for each possible value of the ‘environment’ header even though the granted quota is same.
	// Thus, the client will use this id information (returned from RLS server) to correctly correlate the multiple descriptors/descriptor sets that have been granted with same quota (i.e., share the same quota among multiple descriptors or descriptor sets.)
	//
	// If id is empty, this id field will be ignored. If quota for the same id changes (e.g. due to configuration update), the old quota will be overridden by the new one. Shared quotas referenced by ID will still adhere to expiration after `valid_until`.
	Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

Cacheable quota for responses. Quota can be granted at different levels: either for each individual descriptor or for the whole descriptor set. This is a certain number of requests over a period of time. The client may cache this result and apply the effective RateLimitResponse to future matching requests without querying rate limit service.

When quota expires due to timeout, a new RLS request will also be made. The implementation may choose to preemptively query the rate limit server for more quota on or before expiration or before the available quota runs out. [#not-implemented-hide:]

func (*RateLimitResponse_Quota) Descriptor deprecated

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

Deprecated: Use RateLimitResponse_Quota.ProtoReflect.Descriptor instead.

func (*RateLimitResponse_Quota) GetExpirationSpecifier

func (m *RateLimitResponse_Quota) GetExpirationSpecifier() isRateLimitResponse_Quota_ExpirationSpecifier

func (*RateLimitResponse_Quota) GetId

func (x *RateLimitResponse_Quota) GetId() string

func (*RateLimitResponse_Quota) GetRequests

func (x *RateLimitResponse_Quota) GetRequests() uint32

func (*RateLimitResponse_Quota) GetValidUntil

func (x *RateLimitResponse_Quota) GetValidUntil() *timestamppb.Timestamp

func (*RateLimitResponse_Quota) ProtoMessage

func (*RateLimitResponse_Quota) ProtoMessage()

func (*RateLimitResponse_Quota) ProtoReflect

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

func (*RateLimitResponse_Quota) Reset

func (x *RateLimitResponse_Quota) Reset()

func (*RateLimitResponse_Quota) String

func (x *RateLimitResponse_Quota) String() string

type RateLimitResponse_Quota_ValidUntil

type RateLimitResponse_Quota_ValidUntil struct {
	// Point in time at which the quota expires.
	ValidUntil *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=valid_until,json=validUntil,proto3,oneof"`
}

type RateLimitResponse_RateLimit

type RateLimitResponse_RateLimit struct {

	// A name or description of this limit.
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	// The number of requests per unit of time.
	RequestsPerUnit uint32 `protobuf:"varint,1,opt,name=requests_per_unit,json=requestsPerUnit,proto3" json:"requests_per_unit,omitempty"`
	// The unit of time.
	Unit RateLimitResponse_RateLimit_Unit `` /* 127-byte string literal not displayed */
	// contains filtered or unexported fields
}

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

func (*RateLimitResponse_RateLimit) Descriptor deprecated

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

Deprecated: Use RateLimitResponse_RateLimit.ProtoReflect.Descriptor instead.

func (*RateLimitResponse_RateLimit) GetName

func (x *RateLimitResponse_RateLimit) GetName() string

func (*RateLimitResponse_RateLimit) GetRequestsPerUnit

func (x *RateLimitResponse_RateLimit) GetRequestsPerUnit() uint32

func (*RateLimitResponse_RateLimit) GetUnit

func (*RateLimitResponse_RateLimit) ProtoMessage

func (*RateLimitResponse_RateLimit) ProtoMessage()

func (*RateLimitResponse_RateLimit) ProtoReflect

func (*RateLimitResponse_RateLimit) Reset

func (x *RateLimitResponse_RateLimit) Reset()

func (*RateLimitResponse_RateLimit) String

func (x *RateLimitResponse_RateLimit) String() string

type RateLimitResponse_RateLimit_Unit

type RateLimitResponse_RateLimit_Unit int32

Identifies the unit of of time for rate limit. [#comment: replace by envoy/type/v3/ratelimit_unit.proto in v4]

const (
	// The time unit is not known.
	RateLimitResponse_RateLimit_UNKNOWN RateLimitResponse_RateLimit_Unit = 0
	// The time unit representing a second.
	RateLimitResponse_RateLimit_SECOND RateLimitResponse_RateLimit_Unit = 1
	// The time unit representing a minute.
	RateLimitResponse_RateLimit_MINUTE RateLimitResponse_RateLimit_Unit = 2
	// The time unit representing an hour.
	RateLimitResponse_RateLimit_HOUR RateLimitResponse_RateLimit_Unit = 3
	// The time unit representing a day.
	RateLimitResponse_RateLimit_DAY RateLimitResponse_RateLimit_Unit = 4
	// The time unit representing a month.
	RateLimitResponse_RateLimit_MONTH RateLimitResponse_RateLimit_Unit = 5
	// The time unit representing a year.
	RateLimitResponse_RateLimit_YEAR RateLimitResponse_RateLimit_Unit = 6
)

func (RateLimitResponse_RateLimit_Unit) Descriptor

func (RateLimitResponse_RateLimit_Unit) Enum

func (RateLimitResponse_RateLimit_Unit) EnumDescriptor deprecated

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

Deprecated: Use RateLimitResponse_RateLimit_Unit.Descriptor instead.

func (RateLimitResponse_RateLimit_Unit) Number

func (RateLimitResponse_RateLimit_Unit) String

func (RateLimitResponse_RateLimit_Unit) Type

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://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type RateLimitServiceServer

type RateLimitServiceServer interface {
	// Determine whether rate limiting should take place.
	ShouldRateLimit(context.Context, *RateLimitRequest) (*RateLimitResponse, error)
	// contains filtered or unexported methods
}

RateLimitServiceServer is the server API for RateLimitService service. All implementations must embed UnimplementedRateLimitServiceServer for forward compatibility.

type UnimplementedRateLimitServiceServer

type UnimplementedRateLimitServiceServer struct{}

UnimplementedRateLimitServiceServer must 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 (UnimplementedRateLimitServiceServer) ShouldRateLimit

type UnsafeRateLimitServiceServer

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

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

Jump to

Keyboard shortcuts

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