Documentation ¶
Overview ¶
Package ratelimiter implements a rate limiter.
Index ¶
- Constants
- type Policy
- type RateLimiter
- func (rl *RateLimiter) Close()
- func (rl *RateLimiter) Handle(ctx *context.Context) string
- func (rl *RateLimiter) Inherit(previousGeneration filters.Filter)
- func (rl *RateLimiter) Init()
- func (rl *RateLimiter) Kind() *filters.Kind
- func (rl *RateLimiter) Name() string
- func (rl *RateLimiter) Spec() filters.Spec
- func (rl *RateLimiter) Status() interface{}
- type Rule
- type Spec
- type URLRule
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 `json:"name" jsonschema:"required"` TimeoutDuration string `json:"timeoutDuration,omitempty" jsonschema:"format=duration"` LimitRefreshPeriod string `json:"limitRefreshPeriod,omitempty" jsonschema:"format=duration"` LimitForPeriod int `json:"limitForPeriod,omitempty" jsonschema:"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) Handle ¶
func (rl *RateLimiter) Handle(ctx *context.Context) string
Handle handles HTTP request
func (*RateLimiter) Inherit ¶
func (rl *RateLimiter) Inherit(previousGeneration filters.Filter)
Inherit inherits previous generation of RateLimiter.
func (*RateLimiter) Kind ¶
func (rl *RateLimiter) Kind() *filters.Kind
Kind returns the kind of RateLimiter.
func (*RateLimiter) Name ¶
func (rl *RateLimiter) Name() string
Name returns the name of the RateLimiter filter instance.
func (*RateLimiter) Spec ¶
func (rl *RateLimiter) Spec() filters.Spec
Spec returns the spec used by the RateLimiter
func (*RateLimiter) Status ¶
func (rl *RateLimiter) Status() interface{}
Status returns Status generated by Runtime.
type Rule ¶
type Rule struct { Policies []*Policy `json:"policies" jsonschema:"required"` DefaultPolicyRef string `json:"defaultPolicyRef,omitempty"` URLs []*URLRule `json:"urls" jsonschema:"required"` }
Rule is the detailed config of RateLimiter.
Click to show internal directories.
Click to hide internal directories.