mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Consistent license message for all the go files * Fixing the last set of unconsistencies with the license headers * Addressing PR review comments * Fixing busy.go and busy_test.go license header
27 lines
689 B
Go
27 lines
689 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package utils
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var backoffTimeouts = []time.Duration{50 * time.Millisecond, 100 * time.Millisecond, 200 * time.Millisecond, 200 * time.Millisecond, 400 * time.Millisecond, 400 * time.Millisecond}
|
|
|
|
// ProgressiveRetry executes a BackoffOperation and waits an increasing time before retrying the operation.
|
|
func ProgressiveRetry(operation func() error) error {
|
|
var err error
|
|
|
|
for attempts := 0; attempts < len(backoffTimeouts); attempts++ {
|
|
err = operation()
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
time.Sleep(backoffTimeouts[attempts])
|
|
}
|
|
|
|
return err
|
|
}
|