Move diff from nspcc master and support branches #28

Merged
fyrchik merged 28 commits from move-changes into master 2023-01-25 12:31:47 +00:00
Showing only changes of commit 0aad4c7669 - Show all commits

View file

@ -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
@ -44,7 +42,6 @@ func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClien
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
} }