Versions in this module Expand all Collapse all v0 v0.20.2 Sep 6, 2021 Changes in this version + var ErrResourceNotAvailable = errors.New("naza.ratelimit: resource not available") + var ErrTokenNotEnough = errors.New("naza.ratelimit: token not enough") + type LeakyBucket struct + func NewLeakyBucket(intervalMs int) *LeakyBucket + func (lb *LeakyBucket) MaybeAvailableIntervalMs() int64 + func (lb *LeakyBucket) TryAquire() error + func (lb *LeakyBucket) WaitUntilAquire() + type RateLimiter interface + TryAquire func() error + WaitUntilAquire func() + type TokenBucket struct + func NewTokenBucket(capacity int, prodTokenIntervalMs int, prodTokenNumEveryInterval int) *TokenBucket + func (tb *TokenBucket) Dispose() + func (tb *TokenBucket) TryAquire() error + func (tb *TokenBucket) TryAquireWithNum(num int) error + func (tb *TokenBucket) WaitUntilAquire() + func (tb *TokenBucket) WaitUntilAquireWithNum(num int)