Versions in this module Expand all Collapse all v0 v0.0.3 Jul 5, 2024 v0.0.2 Jun 10, 2024 Changes in this version + const DefaultStrategy + const LimitKeyCacheSize + const LimitKeyExpirationTTL + const LimitTypeByIp + const LimitTypeByKey + var DefaultRegistryCfx = NewRegistry() + var DefaultRegistryEth = NewRegistry() + type Config struct + Strategies map[uint32]*Strategy + type IpLimiter struct + func NewIpLimiter(option Option) *IpLimiter + func (l *IpLimiter) Allow(vc *VisitContext, n int) bool + func (l IpLimiter) GC(timeout time.Duration) + func (l IpLimiter) Update(option Option) bool + type IpLimiterSet struct + func NewIpLimiterSet(s *Strategy) *IpLimiterSet + func (ls IpLimiterSet) GC(timeout time.Duration) + func (ls IpLimiterSet) Get(vc *VisitContext) (Limiter, bool) + func (ls IpLimiterSet) Update(s *Strategy) + type KeyBasedIpLimiterSet struct + func NewKeyBasedIpLimiterSet(s *Strategy) *KeyBasedIpLimiterSet + func (ls KeyBasedIpLimiterSet) GC(timeout time.Duration) + func (ls KeyBasedIpLimiterSet) Get(vc *VisitContext) (Limiter, bool) + func (ls KeyBasedIpLimiterSet) Update(s *Strategy) + type KeyInfo struct + Key string + SID uint32 + Type int + type KeyLimiter struct + func NewKeyLimiter(option Option) *KeyLimiter + func (l *KeyLimiter) Allow(vc *VisitContext, n int) bool + func (l KeyLimiter) GC(timeout time.Duration) + func (l KeyLimiter) Update(option Option) bool + type KeyLimiterSet struct + func NewKeyLimiterSet(s *Strategy) *KeyLimiterSet + func (ls KeyLimiterSet) GC(timeout time.Duration) + func (ls KeyLimiterSet) Get(vc *VisitContext) (Limiter, bool) + func (ls KeyLimiterSet) Update(s *Strategy) + type KeysetFilter struct + KeySet []string + Limit int + SIDs []uint32 + type KeysetLoader func(filter *KeysetFilter) ([]*KeyInfo, error) + type Limiter interface + Allow func(vc *VisitContext, n int) bool + GC func(timeout time.Duration) + Update func(option Option) bool + type LimiterSet interface + GC func(timeout time.Duration) + Get func(vc *VisitContext) (Limiter, bool) + Update func(s *Strategy) + type Option struct + Burst int + Rate rate.Limit + func NewOption(r int, b int) Option + type Registry struct + func NewRegistry() *Registry + func (m *Registry) AutoReload(interval time.Duration, reloader func() *Config, kloader KeysetLoader) + func (m *Registry) GC(timeout time.Duration) + func (m *Registry) Get(vc *VisitContext) (Limiter, bool) + type Strategy struct + ID uint32 + MD5 [md5.Size]byte + Name string + Rules map[string]Option + type VisitContext struct + Ip string + Key string + Resource string