Skip to content

Commit 79e9e3f

Browse files
authored
Merge pull request #1073 from go-redis/fix/failover-dialer-when-available
Use Dialer in Sentinel failover when available
2 parents 79d2c0e + 90d16df commit 79e9e3f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sentinel.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ func (c *sentinelFailover) Close() error {
306306

307307
func (c *sentinelFailover) Pool() *pool.ConnPool {
308308
c.poolOnce.Do(func() {
309-
c.opt.Dialer = c.dial
310-
c.pool = newConnPool(c.opt)
309+
opt := *c.opt
310+
opt.Dialer = c.dial
311+
c.pool = newConnPool(&opt)
311312
})
312313
return c.pool
313314
}
@@ -317,6 +318,9 @@ func (c *sentinelFailover) dial(ctx context.Context, network, addr string) (net.
317318
if err != nil {
318319
return nil, err
319320
}
321+
if c.opt.Dialer != nil {
322+
return c.opt.Dialer(ctx, network, addr)
323+
}
320324
return net.DialTimeout("tcp", addr, c.opt.DialTimeout)
321325
}
322326

0 commit comments

Comments
 (0)