Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SimpleThrottler ¶
type SimpleThrottler struct { // ExecLimit represents the execution count limit after which the // throttler will indicates it's time to throttle ExecLimit uint32 // PauseDuration represents how long the SimpleThrottler consider // we have to throttle execution. PauseDuration time.Duration // ThrottlingMessage is the warning message logged when the throttling is triggered. // An empty message won't log anything. ThrottlingMessage string // contains filtered or unexported fields }
SimpleThrottler is a very basic throttler counting how many times something has been executed and indicating that this execution should be throttled if it has been executed more time ExecLimit. The pause duration is configurable with PauseDuration. After the pause, the throttler resets and restarts with the exact same behavior. There is no automatic decrease whatsoever in the execution count in time. SimpleThrottler is not thread-safe.
func NewSimpleThrottler ¶
func NewSimpleThrottler(execLimit uint32, pauseDuration time.Duration, throttlingMessage string) SimpleThrottler
NewSimpleThrottler creates and returns a SimpleThrottler.
func (*SimpleThrottler) ShouldThrottle ¶
func (t *SimpleThrottler) ShouldThrottle() bool
ShouldThrottle returns a boolean indicating if the throttle consider the execution should be throttled. Not thread-safe.
Click to show internal directories.
Click to hide internal directories.