Documentation ¶
Index ¶
- Constants
- func GenerateRandomLimitKey(limitType LimitType) (string, error)
- type Config
- type ConfigCheckSums
- type FixedWindowOption
- type KeyInfo
- type KeyLoader
- type KeysetFilter
- type LimitAlgoType
- type LimitRule
- type LimitType
- type Registry
- func (r Registry) Allow(ctx acl.Context) error
- func (m *Registry) AutoReload(interval time.Duration, reloader func() (*Config, error))
- func (r *Registry) Create(ctx context.Context, resource, group string) (rate.Limiter, error)
- func (r *Registry) GetGroupAndKey(ctx context.Context, resource string) (group, key string, err error)
- type SVipStatus
- type Strategy
- type TokenBucketOption
Constants ¶
View Source
const ( LimitKeyCacheSize = 5000 LimitKeyExpirationTTL = 60 * time.Second )
View Source
const (
// pre-defined default strategy name
DefaultStrategy = "default"
)
View Source
const (
GCScheduleInterval = 5 * time.Minute
)
View Source
const (
LimitKeyLength = 32
)
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomLimitKey ¶
Types ¶
type ConfigCheckSums ¶
type ConfigCheckSums struct { Strategies map[uint32][md5.Size]byte AllowLists map[uint32][md5.Size]byte }
ConfigCheckSums config md5 checksum
type FixedWindowOption ¶
FixedWindowOption limit option for fixed window
func (*FixedWindowOption) UnmarshalJSON ¶
func (fwo *FixedWindowOption) UnmarshalJSON(data []byte) error
UnmarshalJSON implements `json.Unmarshaler`
type KeyLoader ¶
type KeyLoader struct {
// contains filtered or unexported fields
}
func NewKeyLoader ¶
func NewKeyLoader(ksload ksLoadFunc) *KeyLoader
type KeysetFilter ¶
type LimitAlgoType ¶
type LimitAlgoType string
const ( // rate limit algorithms, only `fixed_window` and `token bucket` are supported for now. LimitAlgoFixedWindow LimitAlgoType = "fixed_window" LimitAlgoTokenBucket LimitAlgoType = "token_bucket" )
type LimitRule ¶
type LimitRule struct { Algo LimitAlgoType Option interface{} }
LimitRule resource limit rule
func (*LimitRule) UnmarshalJSON ¶
type Registry ¶
func NewRegistry ¶
func NewRegistry(kloader *KeyLoader, valFactory acl.ValidatorFactory) *Registry
func (*Registry) AutoReload ¶
type SVipStatus ¶
type SVipStatus = KeyInfo
func SVipStatusFromContext ¶
func SVipStatusFromContext(ctx context.Context) (*SVipStatus, bool)
SVipStatusFromContext returns SVIP status from context
type Strategy ¶
type Strategy struct { ID uint32 // strategy ID Name string // strategy name LimitOptions map[string]interface{} // resource => limit option }
Strategy rate limit strategy
func NewStrategy ¶
func (*Strategy) UnmarshalJSON ¶
UnmarshalJSON implements `json.Unmarshaler`
type TokenBucketOption ¶
FixedWindowOption limit option for token bucket
func NewTokenBucketOption ¶
func NewTokenBucketOption(r, b int) TokenBucketOption
Click to show internal directories.
Click to hide internal directories.