Merge pull request #1734 from monkey92t/failover_tls

fix #1732
This commit is contained in:
Vladimir Mihailenco 2021-04-21 13:30:31 +03:00 committed by GitHub
commit 8d87a75fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -219,14 +219,21 @@ func masterSlaveDialer(
failover.trySwitchMaster(ctx, addr) failover.trySwitchMaster(ctx, addr)
} }
} }
if err != nil { if err != nil {
return nil, err return nil, err
} }
if failover.opt.Dialer != nil { if failover.opt.Dialer != nil {
return failover.opt.Dialer(ctx, network, addr) return failover.opt.Dialer(ctx, network, addr)
} }
return net.DialTimeout("tcp", addr, failover.opt.DialTimeout)
netDialer := &net.Dialer{
Timeout: failover.opt.DialTimeout,
KeepAlive: 5 * time.Minute,
}
if failover.opt.TLSConfig == nil {
return netDialer.DialContext(ctx, network, addr)
}
return tls.DialWithDialer(netDialer, network, addr, failover.opt.TLSConfig)
} }
} }