Versions in this module Expand all Collapse all v0 v0.1.0 Nov 22, 2020 Changes in this version + var ErrInvalidParams = errors.New("[err] invalid params") + var ErrUnknown = errors.New("[err] unknown") + type Cache interface + Close func() error + Get func(key string) (interface{}, bool, error) + Increment func(key string, n int64, ttl time.Duration) error + MGet func(keys ...string) ([]interface{}, bool, error) + Ping func(ctx context.Context) bool + Set func(key string, value interface{}, ttl time.Duration) error + func NewMemoryCache() (Cache, error) + func NewRedisCache(cli *redis.Client) (Cache, error) + type ErrorHandler func(error) + type Option interface + type OptionFunc func(l *limiter) + func WithErrorHandler(h ErrorHandler) OptionFunc + func WithEstimatePeriod(d time.Duration) OptionFunc + func WithMaxLimit(max int64) OptionFunc + func WithMinLimit(min int64) OptionFunc + func WithRevaluateLimit(f RevaluateLimit) OptionFunc + type RateLimiter interface + Acquire func() (bool, error) + Close func() error + CurrentLimit func() (int64, error) + HealthCheck func(ctx context.Context) bool + func NewRateLimiter(serviceName string, cache Cache, opts ...Option) (RateLimiter, error) + type RevaluateLimit func(currentlyLimit, estimatedTimeWindowSize, estimatedTimeWindowUsedCount int64) int64