status-protocol-go/tt/backoff.go

21 lines
414 B
Go
Raw Normal View History

2019-08-31 14:56:28 +00:00
package tt
import (
"time"
"github.com/cenkalti/backoff/v3"
)
func RetryWithBackOff(o func() error) error {
b := backoff.ExponentialBackOff{
InitialInterval: time.Millisecond * 100,
RandomizationFactor: 0.1,
Multiplier: 1,
MaxInterval: time.Second,
MaxElapsedTime: time.Second * 10,
Clock: backoff.SystemClock,
}
b.Reset()
return backoff.Retry(o, &b)
}