Documentation ¶
Index ¶
Constants ¶
View Source
const ( Unknown = iota Allowed HitQuota OverQuota )
Variables ¶
View Source
var ErrUnknownCode = errors.New("unknown status code")
Functions ¶
This section is empty.
Types ¶
type PeriodLimit ¶
type PeriodLimit struct {
// contains filtered or unexported fields
}
func NewPeriodLimit ¶
func NewPeriodLimit(period, quota int, limitStore *redis.Redis, keyPrefix string, opts ...LimitOption) *PeriodLimit
type TokenLimiter ¶
type TokenLimiter struct {
// contains filtered or unexported fields
}
A TokenLimiter controls how frequently events are allowed to happen with in one second.
func NewTokenLimiter ¶
func NewTokenLimiter(rate, burst int, store *redis.Redis, key string) *TokenLimiter
NewTokenLimiter returns a new TokenLimiter that allows events up to rate and permits bursts of at most burst tokens.
func (*TokenLimiter) Allow ¶
func (lim *TokenLimiter) Allow() bool
Allow is shorthand for AllowN(time.Now(), 1).
Click to show internal directories.
Click to hide internal directories.