Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyRateLimiter ¶
type KeyRateLimiter struct {
// contains filtered or unexported fields
}
func NewKeyRateLimiter ¶
func NewKeyRateLimiter(ctx context.Context, cache *redis.Cache, name string, amount int64, every time.Duration) *KeyRateLimiter
NewKeyRateLimiter creates a new rate limiter that will limit to `amount` operations `every` duration. The name will be used to uniquely identify this limiter in the specified redis cache. Consequently, two different limiters in the same cache should NOT have the same name. It is safe to share a single KeyRateLimiter object among multiple consumers to share a limit.
func (*KeyRateLimiter) ForKey ¶
ForKey will check if the given key has exceeded the rate limit for this named limiter
func (*KeyRateLimiter) Name ¶
func (i *KeyRateLimiter) Name() string
Name returns the name of this limiter
Click to show internal directories.
Click to hide internal directories.