mirror of
https://github.com/fhmq/hmq.git
synced 2026-08-30 22:34:52 +00:00
update retry logic
This commit is contained in:
+1
-3
@@ -37,7 +37,6 @@ func (b *Broker) initRPCClient(id, url string) {
|
|||||||
Time: 30 * time.Minute,
|
Time: 30 * time.Minute,
|
||||||
}))
|
}))
|
||||||
var tempDelay time.Duration = 0
|
var tempDelay time.Duration = 0
|
||||||
var maxRetry int = 0
|
|
||||||
for err != nil {
|
for err != nil {
|
||||||
if !b.checkNodeExist(id, url) {
|
if !b.checkNodeExist(id, url) {
|
||||||
return
|
return
|
||||||
@@ -47,7 +46,7 @@ func (b *Broker) initRPCClient(id, url string) {
|
|||||||
if 0 == tempDelay {
|
if 0 == tempDelay {
|
||||||
tempDelay = 1 * time.Second
|
tempDelay = 1 * time.Second
|
||||||
} else {
|
} else {
|
||||||
tempDelay *= 2
|
tempDelay += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if max := 20 * time.Second; tempDelay > max {
|
if max := 20 * time.Second; tempDelay > max {
|
||||||
@@ -55,7 +54,6 @@ func (b *Broker) initRPCClient(id, url string) {
|
|||||||
}
|
}
|
||||||
time.Sleep(tempDelay)
|
time.Sleep(tempDelay)
|
||||||
log.Debug("connect to rpc timeout, retry...")
|
log.Debug("connect to rpc timeout, retry...")
|
||||||
maxRetry++
|
|
||||||
|
|
||||||
conn, err = grpc.Dial(url,
|
conn, err = grpc.Dial(url,
|
||||||
grpc.WithInsecure(),
|
grpc.WithInsecure(),
|
||||||
|
|||||||
Reference in New Issue
Block a user