Documentation ¶
Index ¶
- Constants
- func Validate(ctx context.Context, k8sClient client.Client, rl v1alpha1.RateLimit) error
- type Action
- type Bucket
- type Descriptor
- type DescriptorEntries
- type DescriptorEntry
- type RateLimit
- func (rl *RateLimit) EnableResponseHeaders(enable bool) *RateLimit
- func (rl *RateLimit) Enforce(enforce bool) *RateLimit
- func (rl *RateLimit) For(descriptor Descriptor) *RateLimit
- func (rl *RateLimit) RateLimitConfigPatch() *envoyfilter.ConfigPatch
- func (rl *RateLimit) SetConfigPatches(filter *networkingv1alpha3.EnvoyFilter)
- func (rl *RateLimit) WithDefaultBucket(bucket Bucket) *RateLimit
- type RequestHeader
Constants ¶
const ( LocalRateLimitFilterUrl = "type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit" TypedStruct = "type.googleapis.com/udpa.type.v1.TypedStruct" LocalRateLimitFilterName = "envoy.filters.http.local_ratelimit" )
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate checks the validity of the given RateLimit custom resource. It ensures that there are pods matching the specified selector labels in the same namespace. If no matching pods are found, or if the sidecar injection is not enabled for the pods, or if there are conflicting RateLimit resources, an error is returned.
Parameters: - ctx: The context for the validation operation. - k8sClient: The Kubernetes client used to interact with the cluster. - rl: The RateLimit custom resource to validate.
Returns: - An error if the validation fails, otherwise nil.
Types ¶
type Action ¶
type Action struct {
RequestHeaders RequestHeader
}
Action implements Envoy's Action API fields needed for Rate Limit configuration. See: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#config-route-v3-ratelimit-action
type Bucket ¶
Bucket implements token_bucket fields from Envoy API. See: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/local_ratelimit/v3/local_rate_limit.proto#envoy-v3-api-msg-extensions-filters-http-local-ratelimit-v3-localratelimit
type Descriptor ¶
type Descriptor struct { Entries DescriptorEntries Bucket Bucket }
Descriptor describes each entry for rate limit.
func (Descriptor) Value ¶
func (d Descriptor) Value() *structpb.Value
type DescriptorEntries ¶
type DescriptorEntries []DescriptorEntry
DescriptorEntries wraps a list of DescriptorEntry and implements PBValue interface
func (DescriptorEntries) Value ¶
func (de DescriptorEntries) Value() *structpb.Value
type DescriptorEntry ¶
DescriptorEntry contains routes to which local rate limits apply in scope of each Descriptor
func (DescriptorEntry) Value ¶
func (e DescriptorEntry) Value() *structpb.Value
type RateLimit ¶
type RateLimit struct {
// contains filtered or unexported fields
}
RateLimit contains configuration for Rate Limiting service, exposing functions to manage Envoy's settings.
func NewLocalRateLimit ¶
func NewLocalRateLimit() *RateLimit
NewLocalRateLimit returns RateLimit struct for configuring local rate limits
func (*RateLimit) EnableResponseHeaders ¶
EnableResponseHeaders enables sending `X-Rate-Limit` headers in the response. See: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ratelimit/v3/rate_limit.proto#rate-limit-proto
func (*RateLimit) For ¶
func (rl *RateLimit) For(descriptor Descriptor) *RateLimit
For adds rate limit for specific descriptor. From this descriptor a RequestHeader is created, that is then added to the Action list.
func (*RateLimit) RateLimitConfigPatch ¶
func (rl *RateLimit) RateLimitConfigPatch() *envoyfilter.ConfigPatch
RateLimitConfigPatch generates Istio-compatible ConfigPatch containing local rate limit configuration
func (*RateLimit) SetConfigPatches ¶
func (rl *RateLimit) SetConfigPatches(filter *networkingv1alpha3.EnvoyFilter)
SetConfigPatches parses RateLimit configuration, then applies the parsed ConfigPatches directly into the networkingv1alpha3.EnvoyFilter struct, replacing previous configuration.
func (*RateLimit) WithDefaultBucket ¶
WithDefaultBucket adds configuration for the token bucked used by default.
type RequestHeader ¶
RequestHeader implements Envoy's RequestHeader's API fields. See: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-ratelimit-action-requestheaders
func (RequestHeader) Value ¶
func (rh RequestHeader) Value() *structpb.Value