Options: Use DialContext by default

Use net.Dialer DialContext by default because go-redis supports
contexts.

Resolves #1101
This commit is contained in:
Timothy Yen 2019-07-30 13:03:40 -07:00
parent e58b0108b1
commit 0ecf16e773
2 changed files with 3 additions and 2 deletions

View File

@ -112,7 +112,7 @@ func (opt *Options) init() {
KeepAlive: 5 * time.Minute,
}
if opt.TLSConfig == nil {
return netDialer.Dial(network, addr)
return netDialer.DialContext(ctx, network, addr)
}
return tls.DialWithDialer(netDialer, opt.Network, opt.Addr, opt.TLSConfig)
}

View File

@ -51,7 +51,8 @@ var _ = Describe("Client", func() {
Network: "tcp",
Addr: redisAddr,
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
return net.Dial(network, addr)
var d net.Dialer
return d.DialContext(ctx, network, addr)
},
})