mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 07:17:25 +08:00
add retry to master clients also
This commit is contained in:
@@ -9,13 +9,18 @@ import (
|
||||
|
||||
func Retry(name string, waitTimeLimit time.Duration, job func() error) (err error) {
|
||||
waitTime := time.Second
|
||||
hasErr := false
|
||||
for waitTime < waitTimeLimit {
|
||||
err = job()
|
||||
if err == nil {
|
||||
if hasErr {
|
||||
glog.V(0).Infof("retry %s successfully", name)
|
||||
}
|
||||
break
|
||||
}
|
||||
if strings.Contains(err.Error(), "transport: ") {
|
||||
glog.V(1).Infof("retry %s", name)
|
||||
if strings.Contains(err.Error(), "transport") {
|
||||
hasErr = true
|
||||
glog.V(0).Infof("retry %s", name)
|
||||
time.Sleep(waitTime)
|
||||
waitTime += waitTime / 2
|
||||
}
|
||||
|
Reference in New Issue
Block a user