Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FixedWindow ¶
type FixedWindow struct {
// contains filtered or unexported fields
}
FixedWindow limits rate in a fixed window.
func (*FixedWindow) Expired ¶
func (window *FixedWindow) Expired() bool
func (*FixedWindow) Limit ¶
func (window *FixedWindow) Limit() error
func (*FixedWindow) LimitN ¶
func (window *FixedWindow) LimitN(n int) error
type Limiter ¶
type Limiter interface { Limit() error LimitN(n int) error LimitAt(now time.Time, n int) error // Expired indicates whether limiter not updated for a long time. // Generally, it is used for garbage collection. Expired() bool }
func NewTokenBucket ¶
type TokenBucket ¶
type TokenBucket struct {
// contains filtered or unexported fields
}
func (*TokenBucket) Expired ¶
func (bucket *TokenBucket) Expired() bool
func (*TokenBucket) Limit ¶
func (bucket *TokenBucket) Limit() error
func (*TokenBucket) LimitN ¶
func (bucket *TokenBucket) LimitN(n int) error
Click to show internal directories.
Click to hide internal directories.