1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Fix pool to close all connections when client is closed.

This commit is contained in:
Vladimir Mihailenco
2015-05-02 16:11:18 +03:00
parent f7a1636422
commit f3f44aefbe
6 changed files with 294 additions and 189 deletions

View File

@ -104,14 +104,9 @@ type sentinelClient struct {
func newSentinel(clOpt *Options) *sentinelClient {
opt := clOpt.options()
opt.Password = ""
opt.DB = 0
dialer := func() (net.Conn, error) {
return net.DialTimeout("tcp", clOpt.Addr, opt.DialTimeout)
}
base := &baseClient{
opt: opt,
connPool: newConnPool(newConnFunc(dialer), opt),
connPool: newConnPool(opt.connPoolOptions()),
}
return &sentinelClient{
baseClient: base,
@ -163,7 +158,8 @@ func (d *sentinelFailover) dial() (net.Conn, error) {
func (d *sentinelFailover) Pool() pool {
d.poolOnce.Do(func() {
d.pool = newConnPool(newConnFunc(d.dial), d.opt)
d.opt.Dialer = d.dial
d.pool = newConnPool(d.opt.connPoolOptions())
})
return d.pool
}