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 := backoff.NewExponentialBackOff()
|
||||||
bo.MaxElapsedTime = be.MaxElapsedTime
|
bo.MaxElapsedTime = be.MaxElapsedTime
|
||||||
|
|
||||||
bo.InitialInterval = 1 * time.Second
|
if feature.Flag.Enabled(feature.BackendErrorRedesign) {
|
||||||
bo.Multiplier = 2
|
bo.InitialInterval = 1 * time.Second
|
||||||
|
bo.Multiplier = 2
|
||||||
|
}
|
||||||
if fastRetries {
|
if fastRetries {
|
||||||
// speed up integration tests
|
// speed up integration tests
|
||||||
bo.InitialInterval = 1 * time.Millisecond
|
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(
|
err := retryNotifyErrorWithSuccess(
|
||||||
func() error {
|
func() error {
|
||||||
err := f()
|
err := f()
|
||||||
|
@ -130,7 +137,7 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
backoff.WithContext(withRetryAtLeastOnce(bo), ctx),
|
backoff.WithContext(b, ctx),
|
||||||
func(err error, d time.Duration) {
|
func(err error, d time.Duration) {
|
||||||
if be.Report != nil {
|
if be.Report != nil {
|
||||||
be.Report(msg, err, d)
|
be.Report(msg, err, d)
|
||||||
|
|
Loading…
Reference in a new issue