forked from mirror/redis
Merge pull request #1073 from go-redis/fix/failover-dialer-when-available
Use Dialer in Sentinel failover when available
This commit is contained in:
commit
73d3c18522
|
@ -306,8 +306,9 @@ func (c *sentinelFailover) Close() error {
|
||||||
|
|
||||||
func (c *sentinelFailover) Pool() *pool.ConnPool {
|
func (c *sentinelFailover) Pool() *pool.ConnPool {
|
||||||
c.poolOnce.Do(func() {
|
c.poolOnce.Do(func() {
|
||||||
c.opt.Dialer = c.dial
|
opt := *c.opt
|
||||||
c.pool = newConnPool(c.opt)
|
opt.Dialer = c.dial
|
||||||
|
c.pool = newConnPool(&opt)
|
||||||
})
|
})
|
||||||
return c.pool
|
return c.pool
|
||||||
}
|
}
|
||||||
|
@ -317,6 +318,9 @@ func (c *sentinelFailover) dial(ctx context.Context, network, addr string) (net.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if c.opt.Dialer != nil {
|
||||||
|
return c.opt.Dialer(ctx, network, addr)
|
||||||
|
}
|
||||||
return net.DialTimeout("tcp", addr, c.opt.DialTimeout)
|
return net.DialTimeout("tcp", addr, c.opt.DialTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue