Documentation ¶
Index ¶
- Constants
- type Lim
- type LimiterV1
- func (limiter *LimiterV1) Allow(now time.Time) (ok bool)
- func (limiter *LimiterV1) AllowWithContext(ctx context.Context, now time.Time) (ok bool)
- func (limiter *LimiterV1) Last() time.Time
- func (limiter *LimiterV1) New(interval time.Duration, b int, strong bool) (*LimiterV1, error)
- func (limiter *LimiterV1) Stop()
- type LimiterV2
- func (limiter *LimiterV2) Allow(now time.Time) (ok bool)
- func (limiter *LimiterV2) AllowWithContext(ctx context.Context, now time.Time) (ok bool)
- func (limiter *LimiterV2) Last() time.Time
- func (limiter *LimiterV2) New(interval time.Duration, b int) (*LimiterV2, error)
- func (limiter *LimiterV2) Stop()
- type LimiterV3
- func (limiter *LimiterV3) Allow(now time.Time) (ok bool)
- func (limiter *LimiterV3) AllowWithContext(ctx context.Context, now time.Time) (ok bool)
- func (limiter *LimiterV3) Last() time.Time
- func (limiter *LimiterV3) New(interval time.Duration, b int, strong bool) (*LimiterV3, error)
- func (limiter *LimiterV3) Stop()
- type NewLim
- type RateLimiter
Constants ¶
View Source
const (
RATELIMITER_ClearEveryN = 5
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lim ¶
type LimiterV1 ¶
type LimiterV1 struct {
// contains filtered or unexported fields
}
rate limiter using a time array
func NewLimiterV1 ¶
func (*LimiterV1) AllowWithContext ¶
type LimiterV2 ¶
type LimiterV2 struct {
// contains filtered or unexported fields
}
rate limiter using buffered channel
func NewLimiterV2 ¶
func (*LimiterV2) AllowWithContext ¶
type LimiterV3 ¶
type LimiterV3 struct {
// contains filtered or unexported fields
}
rate limiter using a time array
func NewLimiterV3 ¶
func (*LimiterV3) AllowWithContext ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶
func NewRateLimiter(secs int64, b int) (rl *RateLimiter, err error)
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow(key string) (ok bool)
func (*RateLimiter) AllowWithContext ¶
func (rl *RateLimiter) AllowWithContext(ctx context.Context, key string) (ok bool)
func (*RateLimiter) GetLimiter ¶
func (rl *RateLimiter) GetLimiter(key string) (lim Lim)
func (*RateLimiter) Stop ¶
func (rl *RateLimiter) Stop()
Click to show internal directories.
Click to hide internal directories.