Use Dialer in Sentinel failover when available

This commit is contained in:
Vladimir Mihailenco 2019-06-29 12:19:30 +03:00
parent 056d737e55
commit cdfe26b83c
1 changed files with 6 additions and 2 deletions

View File

@ -306,8 +306,9 @@ func (c *sentinelFailover) Close() error {
func (c *sentinelFailover) Pool() *pool.ConnPool {
c.poolOnce.Do(func() {
c.opt.Dialer = c.dial
c.pool = newConnPool(c.opt)
opt := *c.opt
opt.Dialer = c.dial
c.pool = newConnPool(&opt)
})
return c.pool
}
@ -317,6 +318,9 @@ func (c *sentinelFailover) dial(ctx context.Context, network, addr string) (net.
if err != nil {
return nil, err
}
if c.opt.Dialer != nil {
return c.opt.Dialer(ctx, network, addr)
}
return net.DialTimeout("tcp", addr, c.opt.DialTimeout)
}