Documentation ¶
Index ¶
- Constants
- type BaseRateLimiter
- type Counter
- type CounterLimiter
- type LeakyBucketLimiter
- type Limiter
- func NewCounterRateLimiter(client redis.Cmdable, key string, duration time.Duration, throughput int, ...) (Limiter, error)
- func NewLeakyBucketLimiter(client redis.Cmdable, key string, duration time.Duration, throughput int) (Limiter, error)
- func NewSlideTimeWindowLimiter(throughput int, duration time.Duration, windowBuckets int) (Limiter, error)
- func NewTokenBucketRateLimiter(client redis.Cmdable, key string, duration time.Duration, throughput int, ...) (Limiter, error)
- type SlideTimeWindowLimiter
- type TokenBucketLimiter
Constants ¶
View Source
const ( TokenBucketAlg = iota CounterAlg LeakyBucketAlg )
View Source
const LeakyBucketScript = `` /* 473-byte string literal not displayed */
key Type: string // updateTime key -> {lastUpdateTime}* 1000000 + {microsecond}
View Source
const TokenBucketScript = `` /* 959-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRateLimiter ¶
nolint: govet
type Counter ¶
func NewCounter ¶
func NewCounter() *Counter
type CounterLimiter ¶
type CounterLimiter struct { BaseRateLimiter N int64 // contains filtered or unexported fields }
func (*CounterLimiter) Take ¶
func (r *CounterLimiter) Take() (bool, error)
type LeakyBucketLimiter ¶
type LeakyBucketLimiter struct { BaseRateLimiter // contains filtered or unexported fields }
func (*LeakyBucketLimiter) Take ¶
func (r *LeakyBucketLimiter) Take() (bool, error)
type Limiter ¶
func NewCounterRateLimiter ¶
func NewLeakyBucketLimiter ¶
type SlideTimeWindowLimiter ¶
nolint: govet
func (*SlideTimeWindowLimiter) Count ¶
func (s *SlideTimeWindowLimiter) Count() int
func (*SlideTimeWindowLimiter) Take ¶
func (s *SlideTimeWindowLimiter) Take() (bool, error)
type TokenBucketLimiter ¶
type TokenBucketLimiter struct { BaseRateLimiter N int64 // contains filtered or unexported fields }
func (*TokenBucketLimiter) Take ¶
func (r *TokenBucketLimiter) Take() (bool, error)
Click to show internal directories.
Click to hide internal directories.