Documentation ¶
Index ¶
Constants ¶
View Source
const CLEANUP_FREQUENCY = 120
View Source
const VISITOR_AGE_THRESHOLD = 180
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CooldownConfig ¶ added in v1.1.0
type CooldownLimiter ¶ added in v1.1.0
type CooldownLimiter struct { Name string Mutex sync.Mutex Limiters map[string]Visitor // Threshold at which old visitors are deleted from the map (in seconds since last visit) VisitorAgeThreshold int // Frequency of cleanup (in seconds) CleanupFrequency int Configuration CooldownConfig }
func NewCooldownLimiter ¶ added in v1.1.0
func NewCooldownLimiter(name string, config CooldownConfig) *CooldownLimiter
func (*CooldownLimiter) CleanupLimiters ¶ added in v1.1.0
func (cl *CooldownLimiter) CleanupLimiters()
Function that runs periodically in a goroutine to cleanup old visitors (threshold set with const)
func (*CooldownLimiter) GetLimiter ¶ added in v1.1.0
func (cl *CooldownLimiter) GetLimiter(ip string) *rate.Limiter
func (*CooldownLimiter) LimiterHandler ¶ added in v1.1.0
func (cl *CooldownLimiter) LimiterHandler(next http.HandlerFunc) http.HandlerFunc
type LimiterConfig ¶ added in v1.1.0
type LoginIdentifier ¶ added in v1.1.0
type LoginLimiter ¶ added in v1.1.0
type LoginLimiter struct { Mutex sync.Mutex Limiters map[LoginIdentifier]Visitor // Threshold at which old visitors are deleted from the map (in seconds since last visit) VisitorAgeThreshold int // Frequency of cleanup (in seconds) CleanupFrequency int Configuration CooldownConfig }
func NewLoginLimiter ¶ added in v1.1.0
func NewLoginLimiter(config CooldownConfig) *LoginLimiter
func (*LoginLimiter) CleanupLimiters ¶ added in v1.1.0
func (ll *LoginLimiter) CleanupLimiters()
Function that runs periodically in a goroutine to cleanup old visitors (threshold set with const)
func (*LoginLimiter) GetLimiter ¶ added in v1.1.0
func (ll *LoginLimiter) GetLimiter(userId uint, ip string) *rate.Limiter
type RateLimiter ¶
type RateLimiter struct { Mutex sync.Mutex Limiters map[string]Visitor // Threshold at which old visitors are deleted from the map (in seconds since last visit) VisitorAgeThreshold int // Frequency of cleanup (in seconds) CleanupFrequency int Configuration LimiterConfig }
func NewLimiter ¶
func NewLimiter(config LimiterConfig) *RateLimiter
func (*RateLimiter) CleanupLimiters ¶
func (rl *RateLimiter) CleanupLimiters()
Function that runs periodically in a goroutine to cleanup old visitors (threshold set with const)
func (*RateLimiter) GetLimiter ¶
func (rl *RateLimiter) GetLimiter(ip string) *rate.Limiter
func (*RateLimiter) LimiterHandler ¶
func (rl *RateLimiter) LimiterHandler(next http.HandlerFunc) http.HandlerFunc
Click to show internal directories.
Click to hide internal directories.