Documentation ¶
Index ¶
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 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 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 MD5 [md5.Size]byte `json:"-"` // config data fingerprint }
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.