Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Redis node connection details.
Endpoint string // Required.
Password string
// What is the time unit for the ratelimiter.
// For example, time.Second would limit operations on
// per-second basis. Duration is a required field.
Duration time.Duration
}
Config describes a Redis based rate limiter.
type RateLimiter ¶
type RateLimiter interface {
// Limit decides whether an operation signified by key should
// be limited or not, based on max operation allowed.
Limit(ctx context.Context, key string, max int64) (bool, error)
}
RateLimiter is the interface that wraps the Limit method.
A RateLimiter implementation helps limit a given operation, by keeping track of calls made to Limit.
func NewRateLimiter ¶
func NewRateLimiter(ctx context.Context, conf *Config) (RateLimiter, error)
NewRateLimiter returns an AWS ElastiCache Redis based implementation of RateLimiter.
Click to show internal directories.
Click to hide internal directories.