Retry Environment Recovery
This commit is contained in:

committed by
Sebastian Serth

parent
89c18ad45c
commit
73759f8a3c
@ -9,6 +9,8 @@ var (
|
||||
log = logging.GetLogger("util")
|
||||
// MaxConnectionRetriesExponential is the default number of retries. It's exported for testing reasons.
|
||||
MaxConnectionRetriesExponential = 18
|
||||
// InitialWaitingDuration is the default initial duration of waiting after a failed time.
|
||||
InitialWaitingDuration = time.Second
|
||||
)
|
||||
|
||||
// RetryExponentialAttempts executes the passed function
|
||||
@ -28,6 +30,10 @@ func RetryExponentialAttempts(attempts int, sleep time.Duration, f func() error)
|
||||
return err
|
||||
}
|
||||
|
||||
func RetryExponential(sleep time.Duration, f func() error) error {
|
||||
func RetryExponentialDuration(sleep time.Duration, f func() error) error {
|
||||
return RetryExponentialAttempts(MaxConnectionRetriesExponential, sleep, f)
|
||||
}
|
||||
|
||||
func RetryExponential(f func() error) error {
|
||||
return RetryExponentialDuration(InitialWaitingDuration, f)
|
||||
}
|
||||
|
Reference in New Issue
Block a user