NewDialer returns a function that will be used as the default dialer when none is specified in Options.Dialer.
(opt *Options)
| 445 | // NewDialer returns a function that will be used as the default dialer |
| 446 | // when none is specified in Options.Dialer. |
| 447 | func NewDialer(opt *Options) func(context.Context, string, string) (net.Conn, error) { |
| 448 | return func(ctx context.Context, network, addr string) (net.Conn, error) { |
| 449 | netDialer := &net.Dialer{ |
| 450 | Timeout: opt.DialTimeout, |
| 451 | KeepAlive: 5 * time.Minute, |
| 452 | } |
| 453 | if opt.TLSConfig == nil { |
| 454 | return netDialer.DialContext(ctx, network, addr) |
| 455 | } |
| 456 | return tls.DialWithDialer(netDialer, network, addr, opt.TLSConfig) |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | // ParseURL parses a URL into Options that can be used to connect to Redis. |
| 461 | // Scheme is required. |