From c33ad3c4744c1137bf79e00d2255d5aed674a76a Mon Sep 17 00:00:00 2001
From: Pavel Karpy
Date: Mon, 16 Jan 2023 15:47:17 +0300
Subject: [PATCH] [#2164] node: Use `reconnect_interval` from config
Not always the default one.
Signed-off-by: Pavel Karpy
Signed-off-by: Evgenii Stratonikov
---
pkg/network/cache/multi.go | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/pkg/network/cache/multi.go b/pkg/network/cache/multi.go
index 2689456310..bf4beab547 100644
--- a/pkg/network/cache/multi.go
+++ b/pkg/network/cache/multi.go
@@ -30,8 +30,6 @@ type multiClient struct {
addr network.AddressGroup
opts ClientCacheOpts
-
- reconnectInterval time.Duration
}
const defaultReconnectInterval = time.Second * 30
@@ -41,10 +39,9 @@ func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClien
opts.ReconnectTimeout = defaultReconnectInterval
}
return &multiClient{
- clients: make(map[string]*singleClient),
- addr: addr,
- opts: opts,
- reconnectInterval: defaultReconnectInterval,
+ clients: make(map[string]*singleClient),
+ addr: addr,
+ opts: opts,
}
}
@@ -340,7 +337,7 @@ func (x *multiClient) client(addr network.Address) (clientcore.Client, error) {
c.RUnlock()
return cl, nil
}
- if x.reconnectInterval != 0 && time.Since(c.lastAttempt) < x.reconnectInterval {
+ if x.opts.ReconnectTimeout != 0 && time.Since(c.lastAttempt) < x.opts.ReconnectTimeout {
c.RUnlock()
return nil, errRecentlyFailed
}
@@ -363,7 +360,7 @@ func (x *multiClient) client(addr network.Address) (clientcore.Client, error) {
return c.client, nil
}
- if x.reconnectInterval != 0 && time.Since(c.lastAttempt) < x.reconnectInterval {
+ if x.opts.ReconnectTimeout != 0 && time.Since(c.lastAttempt) < x.opts.ReconnectTimeout {
return nil, errRecentlyFailed
}