forked from TrueCloudLab/frostfs-node
[#2164] node: Use reconnect_interval
from config
Not always the default one. Signed-off-by: Pavel Karpy <p.karpy@yadro.com> Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
0d8366f475
commit
c33ad3c474
1 changed files with 5 additions and 8 deletions
13
pkg/network/cache/multi.go
vendored
13
pkg/network/cache/multi.go
vendored
|
@ -30,8 +30,6 @@ type multiClient struct {
|
||||||
addr network.AddressGroup
|
addr network.AddressGroup
|
||||||
|
|
||||||
opts ClientCacheOpts
|
opts ClientCacheOpts
|
||||||
|
|
||||||
reconnectInterval time.Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultReconnectInterval = time.Second * 30
|
const defaultReconnectInterval = time.Second * 30
|
||||||
|
@ -41,10 +39,9 @@ func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClien
|
||||||
opts.ReconnectTimeout = defaultReconnectInterval
|
opts.ReconnectTimeout = defaultReconnectInterval
|
||||||
}
|
}
|
||||||
return &multiClient{
|
return &multiClient{
|
||||||
clients: make(map[string]*singleClient),
|
clients: make(map[string]*singleClient),
|
||||||
addr: addr,
|
addr: addr,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
reconnectInterval: defaultReconnectInterval,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +337,7 @@ func (x *multiClient) client(addr network.Address) (clientcore.Client, error) {
|
||||||
c.RUnlock()
|
c.RUnlock()
|
||||||
return cl, nil
|
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()
|
c.RUnlock()
|
||||||
return nil, errRecentlyFailed
|
return nil, errRecentlyFailed
|
||||||
}
|
}
|
||||||
|
@ -363,7 +360,7 @@ func (x *multiClient) client(addr network.Address) (clientcore.Client, error) {
|
||||||
return c.client, nil
|
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
|
return nil, errRecentlyFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue