Skip to content

Commit

Permalink
re-arrange if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Apr 18, 2024
1 parent 5d2a1b2 commit 2534069
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2534069

Please sign in to comment.