ratelimiter

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Kind is the kind of RateLimiter.
	Kind = "RateLimiter"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	Name               string `yaml:"name" jsonschema:"required"`
	TimeoutDuration    string `yaml:"timeoutDuration" jsonschema:"omitempty,format=duration"`
	LimitRefreshPeriod string `yaml:"limitRefreshPeriod" jsonschema:"omitempty,format=duration"`
	LimitForPeriod     int    `yaml:"limitForPeriod" jsonschema:"omitempty,minimum=1"`
}

Policy defines the policy of a rate limiter

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

RateLimiter defines the rate limiter

func (*RateLimiter) Close

func (rl *RateLimiter) Close()

Close closes RateLimiter.

func (*RateLimiter) DefaultSpec

func (rl *RateLimiter) DefaultSpec() interface{}

DefaultSpec returns the default spec of RateLimiter.

func (*RateLimiter) Description

func (rl *RateLimiter) Description() string

Description returns the description of RateLimiter

func (*RateLimiter) Handle

func (rl *RateLimiter) Handle(ctx context.HTTPContext) string

Handle handles HTTP request

func (*RateLimiter) Inherit

func (rl *RateLimiter) Inherit(filterSpec *httppipeline.FilterSpec, previousGeneration httppipeline.Filter)

Inherit inherits previous generation of RateLimiter.

func (*RateLimiter) Init

func (rl *RateLimiter) Init(filterSpec *httppipeline.FilterSpec)

Init initializes RateLimiter.

func (*RateLimiter) Kind

func (rl *RateLimiter) Kind() string

Kind returns the kind of RateLimiter.

func (*RateLimiter) Results

func (rl *RateLimiter) Results() []string

Results returns the results of RateLimiter.

func (*RateLimiter) Status

func (rl *RateLimiter) Status() interface{}

Status returns Status generated by Runtime.

type Spec

type Spec struct {
	Policies         []*Policy  `yaml:"policies" jsonschema:"required"`
	DefaultPolicyRef string     `yaml:"defaultPolicyRef" jsonschema:"omitempty"`
	URLs             []*URLRule `yaml:"urls" jsonschema:"required"`
}

Spec is the configuration of a rate limiter

func (Spec) Validate

func (spec Spec) Validate() error

Validate implements custom validation for Spec

type URLRule

type URLRule struct {
	urlrule.URLRule `yaml:",inline"`
	// contains filtered or unexported fields
}

URLRule defines the rate limiter rule for a URL pattern

Jump to

Keyboard shortcuts

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