@@ -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