Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Duration is the duration on which the interval "ticks" (if a jitter is // applied, this represents the upper bound of the range). Duration time.Duration // FirstDuration is an optional special duration to be used for the first // "tick" of the interval. This duration is not jittered. FirstDuration time.Duration // Jitter is an optional jitter to be applied to each step of the interval. // It is usually preferable to use a smaller jitter (e.g. NewSeventhJitter()) // for this parameter, since periodic operations are typically costly and the // effect of the jitter is cumulative. Jitter retryutils.Jitter }
Config configures an interval. The only required parameter is the Duration field which *must* be a positive duration.
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval functions similarly to time.Ticker, with the added benefit of being able to specify a custom duration for the first "tick", and an optional per-tick jitter. When attempting to stagger periodic operations it is recommended to apply a large jitter to the first duration, and provide a small jitter for the per-tick jitter. This will ensure that operations started at similar times will have varying initial interval states, while minimizing the amount of extra work introduced by the per-tick jitter.
func New ¶
New creates a new interval instance. This function panics on non-positive interval durations (equivalent to time.NewTicker).