Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrSleeperCancelled ¶ added in v0.1.12
type ErrSleeperCancelled struct{}
ErrSleeperCancelled returned when a sleeper is cancelled early
func (*ErrSleeperCancelled) Error ¶ added in v0.1.12
func (e *ErrSleeperCancelled) Error() string
type NextSleepDuration ¶
NextSleepDuration provided to set a custom func to determine the next sleep duration
type Sleeper ¶
type Sleeper struct {
// contains filtered or unexported fields
}
Sleeper is a more complex version of the base timer
func NewCustomSleeper ¶
func NewCustomSleeper(sleepDuration time.Duration, sleepFunc NextSleepDuration) *Sleeper
NewCustomSleeper returns a sleeper that will use a custom sleeper function to get the interval duration
func NewExponentialSleeper ¶
NewExponentialSleeper returns a sleeper that will sleep with an exponentially increasing interval useful for exponential backoff
func NewLinearSleeper ¶
NewLinearSleeper returns a sleeper that will sleep with an linearly increasing interval useful for linear backoff
func NewSleeper ¶
NewSleeper returns a sleeper that will sleep for the given sleep duration every time Sleep() is called
func (*Sleeper) Cancel ¶
func (s *Sleeper) Cancel()
Cancel cancels the sleeper, causing any running sleeper routines to return
func (*Sleeper) Sleep ¶
Sleep returns a channel that will return a ErrSleeperCancelled error if context is cancelled before the next sleep interval completes, nil otherwise
func (*Sleeper) WithAddRandom ¶
WithAddRandom waits for an additional duration from 0 to the given duration every interval