From 2534069320421ef6ceb85f6cc8679ffd7b0c0f9c Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 17 Apr 2024 22:26:35 -0700 Subject: [PATCH] re-arrange if statement --- client/pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/pool.go b/client/pool.go index 9e95104..c377008 100644 --- a/client/pool.go +++ b/client/pool.go @@ -132,10 +132,10 @@ func (p *Pool) connector(ctx context.Context, now time.Time) { func (p *Pool) fillConnectionPool(ctx context.Context, now time.Time, toCreate int) { if p.client.RoundRobinConfig != nil { - if toCreate == 0 { + if toCreate == 0 || len(p.connections) > 0 { // Keep this up to date, or the logic will skip to the next server prematurely. p.client.lastConn = now - } else if len(p.connections) == 0 && now.Sub(p.client.lastConn) > p.client.RetryInterval { + } else if now.Sub(p.client.lastConn) > p.client.RetryInterval { // We need more connections and the last successful connection was too long ago. // Restart and skip to the next server in the round robin target list. defer p.client.restart(ctx)