Skip to content

Commit

Permalink
just update the pool configuration if the options changed, because re…
Browse files Browse the repository at this point in the history
…creating the pool,existed idleconnection, if any, will be dropped without closing
  • Loading branch information
elebore committed May 26, 2018
1 parent c666558 commit 541e894
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ func (r *rpcClient) Init(opts ...Option) error {
o(&r.opts)
}

// recreate the pool if the options changed
// update pool configuration if the options changed
if size != r.opts.PoolSize || ttl != r.opts.PoolTTL {
r.pool = newPool(r.opts.PoolSize, r.opts.PoolTTL)
r.pool.Lock()
r.pool.size = r.opts.PoolSize
r.pool.ttl = int64(r.opts.PoolTTL.Seconds())
r.pool.Unlock()
}

return nil
Expand Down

0 comments on commit 541e894

Please sign in to comment.