Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Type defines the type of the Limiter Type Type // Address defines the Redis server address Address string // RateLimit defines the rate limit in queries per Interval RateLimit float64 // BurstLimit defines the burst limit or bucket size of the Limiter BurstLimit int // Interval defines the token refresh rate of RateLimit tokens per Interval Interval time.Duration // FailOpen determines if Allow should return true on Redis server errors FailOpen bool }
Config defines a struct passed to New to configure a Limiter
type Limiter ¶
type Limiter interface { // Allow returns true if an event may happen for the given ID Allow(id string) bool // AllowN returns true if the given number of events may happen for the // given ID AllowN(id string, n int) bool // AllowDynamic returns true if an event may happen for the given ID taking // into consideration the given rate and burst limits AllowDynamic(id string, rate float64, burst int) bool // AllowNDynamic returns true if the given number of events may happen for // the given ID taking into consideration the given rate and burst limits AllowNDynamic(id string, n int, rate float64, burst int) bool // Rate returns the default rate limit Rate() float64 // Burst returns the default burst limit Burst() int }
Limiter defines a rate limiter interface
Click to show internal directories.
Click to hide internal directories.