Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyAlreadyExists = errorutil.NewWithTag("MultiLimiter", "key already exists") ErrKeyMissing = errorutil.NewWithTag("MultiLimiter", "key does not exist") )
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter allows a burst of request during the defined duration
func NewLeakyBucket ¶ added in v0.0.43
NewUnlimited create a bucket with approximated unlimited tokens
func NewUnlimited ¶
NewUnlimited create a bucket with approximated unlimited tokens
func (*Limiter) SetDuration ¶ added in v0.0.33
GetLimit returns current rate limit per given duration
type MultiLimiter ¶ added in v0.0.3
type MultiLimiter struct {
// contains filtered or unexported fields
}
MultiLimiter is wrapper around Limiter than can limit based on a key
func NewMultiLimiter ¶ added in v0.0.3
func NewMultiLimiter(ctx context.Context, opts *Options) (*MultiLimiter, error)
NewMultiLimiter : Limits
func (*MultiLimiter) Add ¶ added in v0.0.3
func (m *MultiLimiter) Add(opts *Options) error
Add new bucket with key
func (*MultiLimiter) AddAndTake ¶ added in v0.0.6
func (m *MultiLimiter) AddAndTake(opts *Options)
AddAndTake adds key if not present and then takes token from bucket
func (*MultiLimiter) CanTake ¶ added in v0.0.9
func (m *MultiLimiter) CanTake(key string) bool
CanTake checks if the rate limiter with the given key has any token
func (*MultiLimiter) GetLimit ¶ added in v0.0.3
func (m *MultiLimiter) GetLimit(key string) (uint, error)
GetLimit returns current ratelimit of given key
func (*MultiLimiter) Stop ¶ added in v0.0.4
func (m *MultiLimiter) Stop(keys ...string)
Stop internal limiters with defined keys or all if no key is provided
func (*MultiLimiter) Take ¶ added in v0.0.3
func (m *MultiLimiter) Take(key string) error
Take one token from bucket returns error if key not present