Skip to content

Commit

Permalink
always attempt getConn to init the pool first so the following _withC…
Browse files Browse the repository at this point in the history
…onn will have the valid conn to resolve hystrix
  • Loading branch information
Runze Cui committed Sep 3, 2024
1 parent 51fcf37 commit 3a8706b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,16 @@ func (c *baseClient) withConn(
return err
}

// always attempt getConn to init the pool first so the following _withConn will have the valid conn
cn, connerr := c.getConn(ctx)
if connerr != nil {
return connerr
}

defer func() {
c.releaseConn(ctx, cn, connerr)
}()

err := limiter.Execute(func() error {
return c._withConn(ctx, fn)
})
Expand Down

0 comments on commit 3a8706b

Please sign in to comment.