From bbb84ff7095fb05574db58efa48f50c063de55c4 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 24 Jun 2016 21:00:57 -0700 Subject: [PATCH] discovery: use pkg/transport to create http transport --- discovery/discovery.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/discovery/discovery.go b/discovery/discovery.go index 3dac28b92..d53c46114 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -20,7 +20,6 @@ import ( "errors" "fmt" "math" - "net" "net/http" "net/url" "path" @@ -30,6 +29,7 @@ import ( "time" "github.com/coreos/etcd/client" + "github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/pkg/types" "github.com/coreos/pkg/capnslog" "github.com/jonboulle/clockwork" @@ -124,16 +124,15 @@ func newDiscovery(durl, dproxyurl string, id types.ID) (*discovery, error) { if err != nil { return nil, err } + + // TODO: add ResponseHeaderTimeout back when watch on discovery service writes header early + tr, err := transport.NewTransport(transport.TLSInfo{}, 30*time.Second) + if err != nil { + return nil, err + } + tr.Proxy = pf cfg := client.Config{ - Transport: &http.Transport{ - Proxy: pf, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - // TODO: add ResponseHeaderTimeout back when watch on discovery service writes header early - }, + Transport: tr, Endpoints: []string{u.String()}, } c, err := client.New(cfg)