Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FF bool
FF is set to Fast Forward time during testing. When true delays are 100 times shorter.
Functions ¶
This section is empty.
Types ¶
type Exponential ¶
type Exponential struct {
// contains filtered or unexported fields
}
Exponential Sleep
func NewExponential ¶
func NewExponential(max time.Duration) *Exponential
NewExponential returns an exponential Sleep. First it sleeps 0.1 sec then 0.2 etc, sleep time is capped at max.
Examples:
Limit by number of retries:
for exp := backoff.NewExponential(10 * time.Second); exp.Retries() < 10; exp.Sleep() {
Limit by time:
end := time.Now().Add(10 * time.Minute)
for exp := backoff.NewExponential(10 * time.Second); !time.Now().After(end); exp.Sleep() {
func (*Exponential) Retries ¶
func (ex *Exponential) Retries() int
Retries returns the number of retries so far.
func (*Exponential) Sleep ¶
func (ex *Exponential) Sleep()
Sleep exponentially longer on each invocation with a limit of max time.
Click to show internal directories.
Click to hide internal directories.