Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoMoreTokens = errors.New("no more tokens, pls wait and retry")
)
nolint
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter interface { Take() error // Take take one token, if met error, must be ErrNoMoreTokens Remains() int // how many tokens remains, always used to check if reached limit line Taken() int // how many tokens has been taken SetLimit(w time.Duration, n int) // change limit settings on fly String() string // print limiter text message }
Limiter controls how frequently events are allowed to happen
Click to show internal directories.
Click to hide internal directories.