Documentation
¶
Overview ¶
Package tickers provides specialized ticker implementations with configurable timing behaviors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exponential ¶
type Exponential struct {
// C is the channel on which the ticks are delivered.
C chan time.Time
// contains filtered or unexported fields
}
Exponential is a ticker which provides a channel sending time values with an exponentially increasing interval.
func NewExponential ¶
func NewExponential(initialDuration time.Duration, factor float64, opts ...ExponentialOption) *Exponential
NewExponential creates and starts a new exponential ticker with the given initial duration and exponential factor. The ticker will send the current time on its channel at exponentially increasing intervals. The first tick occurs after initialDuration, the second after initialDuration * factor, the third after initialDuration * factor^2, and so on. Optional ExponentialOption functions can be provided to configure the ticker (e.g., WithJitter).
func (*Exponential) Stop ¶
func (e *Exponential) Stop()
Stop stops the exponential ticker and releases associated resources. After calling Stop, no more ticks will be sent on the ticker's channel.
type ExponentialOption ¶
type ExponentialOption func(*Exponential)
ExponentialOption is a function which can be provided to the NewExponential function to configure the exponential ticker.
func WithJitter ¶
func WithJitter(jitter time.Duration) ExponentialOption
WithJitter returns an ExponentialOption that adds random jitter to each interval. The jitter is a random duration between 0 and the provided jitter value that is added to each interval.