Documentation ¶
Overview ¶
Package throttle is function throttling package
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Throttler ¶
type Throttler interface {
Do(f func())
}
Throttler is an interface that will perform exactly one action per duration.(should use New constructor only) Do call the function f if a specified duration has passed since the last function f was called for this instance of Throttle. In other words, given
var throttle = Throttle.New(time.Minute)
if throttle.Do(f) is called multiple times within a minute, only the first call will invoke f, even if f has a different value in each invocation. Waiting for a minute or a new instance of Throttle is required for each function to execute.
Click to show internal directories.
Click to hide internal directories.