forked from TrueCloudLab/restic
backend/retry: feature flag new retry behavior
This commit is contained in:
parent
723247c8e5
commit
e4a48085ae
1 changed files with 11 additions and 4 deletions
|
@ -108,9 +108,10 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
|
|||
bo := backoff.NewExponentialBackOff()
|
||||
bo.MaxElapsedTime = be.MaxElapsedTime
|
||||
|
||||
if feature.Flag.Enabled(feature.BackendErrorRedesign) {
|
||||
bo.InitialInterval = 1 * time.Second
|
||||
bo.Multiplier = 2
|
||||
|
||||
}
|
||||
if fastRetries {
|
||||
// speed up integration tests
|
||||
bo.InitialInterval = 1 * time.Millisecond
|
||||
|
@ -120,6 +121,12 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
|
|||
}
|
||||
}
|
||||
|
||||
var b backoff.BackOff = withRetryAtLeastOnce(bo)
|
||||
if !feature.Flag.Enabled(feature.BackendErrorRedesign) {
|
||||
// deprecated behavior
|
||||
b = backoff.WithMaxRetries(b, 10)
|
||||
}
|
||||
|
||||
err := retryNotifyErrorWithSuccess(
|
||||
func() error {
|
||||
err := f()
|
||||
|
@ -130,7 +137,7 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
|
|||
}
|
||||
return err
|
||||
},
|
||||
backoff.WithContext(withRetryAtLeastOnce(bo), ctx),
|
||||
backoff.WithContext(b, ctx),
|
||||
func(err error, d time.Duration) {
|
||||
if be.Report != nil {
|
||||
be.Report(msg, err, d)
|
||||
|
|
Loading…
Reference in a new issue