From cdfe26b83c6c7e7db6dfb93a33a378d4a4cbe7f3 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sat, 29 Jun 2019 12:19:30 +0300 Subject: [PATCH] Use Dialer in Sentinel failover when available --- sentinel.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sentinel.go b/sentinel.go index 1f906d66..4c75de90 100644 --- a/sentinel.go +++ b/sentinel.go @@ -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) }