Documentation
¶
Index ¶
- type Backend
- type Option
- type Service
- func (s *Service) AddToWindow(ctx context.Context, key string, timestamp int64, member string, ...) error
- func (s *Service) Allow(key string, rate float64, burst int) bool
- func (s *Service) CountInWindow(ctx context.Context, key string, min, max int64) (int, error)
- func (s *Service) GetTTL(ctx context.Context, key string) (time.Duration, error)
- func (s *Service) GetWindowEntries(ctx context.Context, key string, start, stop int) ([]string, error)
- func (s *Service) Increment(ctx context.Context, key string, value int64, expiration time.Duration) (int64, error)
- func (s *Service) LocalBucketCount() int
- func (s *Service) RemoveFromWindow(ctx context.Context, key string, cutoff int64) error
- func (s *Service) Start() error
- func (s *Service) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
IncrExpire(ctx context.Context, key string, value int64, expiration time.Duration) (int64, error)
WindowAdd(ctx context.Context, key string, score int64, member string, expiration time.Duration) error
WindowRemove(ctx context.Context, key string, cutoff int64) error
WindowCount(ctx context.Context, key string, min, max int64) (int, error)
WindowMembers(ctx context.Context, key string, start, stop int64) ([]string, error)
TTL(ctx context.Context, key string) (time.Duration, error)
Close() error
}
func NewMemoryBackend ¶
func NewMemoryBackend() Backend
func NewMemoryBackendWithCleanup ¶
NewMemoryBackendWithCleanup overrides the stale-entry eviction thresholds, primarily for tests. ttl is how long an idle entry is retained before being purged; interval is how often the background sweep runs (lazily, on access).
func NewRedisBackend ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewWithBackend ¶
func NewWithRedisClient ¶
func (*Service) AddToWindow ¶
func (*Service) CountInWindow ¶
func (*Service) GetWindowEntries ¶
func (*Service) LocalBucketCount ¶
func (*Service) RemoveFromWindow ¶
Click to show internal directories.
Click to hide internal directories.