mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcd: manually construct HTTP client for peer communication
This commit is contained in:
parent
5470a6d3d6
commit
0c7351c309
10
main.go
10
main.go
@ -151,13 +151,9 @@ func startEtcd() {
|
||||
n = raft.RestartNode(id, peers.IDs(), 10, 1, snapshot, st, ents)
|
||||
}
|
||||
|
||||
pt := &http.Transport{
|
||||
// timeouts copied from http.DefaultTransport
|
||||
Dial: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).Dial,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
pt, err := transport.NewTransport()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
s := &etcdserver.EtcdServer{
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewListener(addr string, info TLSInfo) (net.Listener, error) {
|
||||
@ -27,6 +29,18 @@ func NewListener(addr string, info TLSInfo) (net.Listener, error) {
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func NewTransport() (*http.Transport, error) {
|
||||
t := &http.Transport{
|
||||
// timeouts taken from http.DefaultTransport
|
||||
Dial: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).Dial,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
type TLSInfo struct {
|
||||
CertFile string
|
||||
KeyFile string
|
||||
|
Loading…
x
Reference in New Issue
Block a user