throttler

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DESTINATION_LEVEL = "destination"
	USER_LEVEL        = "user"
	ALL_LEVELS        = "all"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandleT

type HandleT struct {
	// contains filtered or unexported fields
}

HandleT is a Handle for event limiter

func (*HandleT) CheckLimitReached

func (throttler *HandleT) CheckLimitReached(destID, userID string, currentTime time.Time) bool

LimitReached returns true if number of events in the rolling window is less than the max events allowed, else false

func (*HandleT) Dec

func (throttler *HandleT) Dec(destID, userID string, count int64, currentTime time.Time, atLevel string)

Dec decrements the destLimiter and userLimiter counters by count passed If destID or userID passed is empty, we don't decrement the counters.

func (*HandleT) Inc

func (throttler *HandleT) Inc(destID, userID string, currentTime time.Time)

Inc increases the destLimiter and userLimiter counters. If destID or userID passed is empty, we don't increment the counters.

func (*HandleT) IsDestLevelEnabled

func (throttler *HandleT) IsDestLevelEnabled() bool

func (*HandleT) IsEnabled

func (throttler *HandleT) IsEnabled() bool

func (*HandleT) IsUserLevelEnabled

func (throttler *HandleT) IsUserLevelEnabled() bool

func (*HandleT) SetUp

func (throttler *HandleT) SetUp(destName string)

SetUp eventLimiter

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

type Throttler

type Throttler interface {
	CheckLimitReached(destID, userID string, currentTime time.Time) bool
	Inc(destID, userID string, currentTime time.Time)
	Dec(destID, userID string, count int64, currentTime time.Time, atLevel string)
	IsEnabled() bool
	IsUserLevelEnabled() bool
	IsDestLevelEnabled() bool
}

Throttler is an interface for throttling functions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL