update sleep time

This commit is contained in:
fanyangyang 2020-05-18 19:32:58 +08:00
parent 07260308af
commit 6c84e5250e
2 changed files with 4 additions and 9 deletions

View File

@ -145,16 +145,14 @@ func CreateManager(config config.Config) (err error) {
return fmt.Errorf("DB drivers: %s not supported", config.DBType)
}
var tryTime time.Duration
for {
tryTime++
defaultManager, err = mysql.CreateManager(config)
if err == nil {
logrus.Infof("db manager is ready")
break
}
logrus.Errorf("get db manager failed, try time is %v,%s", tryTime, err.Error())
time.Sleep((5 + tryTime*10) * time.Second)
logrus.Errorf("get db manager failed, try time is %d,%s", 10, err.Error())
time.Sleep(10 * time.Second)
}
//TODO:etcd db plugin
//defaultManager, err = etcd.CreateManager(config)

View File

@ -115,19 +115,16 @@ func NewClient(ctx context.Context, clientArgs *ClientArgs) (*v3.Client, error)
}
config.TLS = tlsConfig
}
var tryTime time.Duration
tryTime = 0
var etcdClient *v3.Client
var err error
for {
tryTime++
etcdClient, err = clientv3.New(config)
if err == nil {
logrus.Infof("etcd.v3 client is ready")
return etcdClient, nil
}
logrus.Errorf("create etcd.v3 client failed, try time is %v,%s", tryTime, err.Error())
time.Sleep((5 + tryTime*10) * time.Second)
logrus.Errorf("create etcd.v3 client failed, try time is %d,%s", 10, err.Error())
time.Sleep(10 * time.Second)
}
return nil, err
}