Mono repo -> Master (#22553)
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
Этот коммит содержится в:
26
server/channels/utils/backoff.go
Обычный файл
26
server/channels/utils/backoff.go
Обычный файл
@@ -0,0 +1,26 @@
|
||||
// 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
|
||||
}
|
||||
Ссылка в новой задаче
Block a user