Skip to content

Commit 007c937

Browse files
committed
Configure http transport
1 parent 325ff03 commit 007c937

File tree

1 file changed

+19
-1
lines changed
  • components/registry-facade/cmd

1 file changed

+19
-1
lines changed

components/registry-facade/cmd/run.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"crypto/sha256"
99
"encoding/hex"
1010
"io"
11+
"net"
1112
"net/http"
1213
"os"
1314
"os/signal"
@@ -64,7 +65,7 @@ var runCmd = &cobra.Command{
6465

6566
promreg := prometheus.NewRegistry()
6667
gpreg := prometheus.WrapRegistererWithPrefix("gitpod_registry_facade_", promreg)
67-
rtt, err := registry.NewMeasuringRegistryRoundTripper(http.DefaultTransport, prometheus.WrapRegistererWithPrefix("downstream_", gpreg))
68+
rtt, err := registry.NewMeasuringRegistryRoundTripper(newDefaultTransport(), prometheus.WrapRegistererWithPrefix("downstream_", gpreg))
6869
if err != nil {
6970
log.WithError(err).Fatal("cannot registry metrics")
7071
}
@@ -125,6 +126,23 @@ var runCmd = &cobra.Command{
125126
},
126127
}
127128

129+
func newDefaultTransport() *http.Transport {
130+
return &http.Transport{
131+
Proxy: http.ProxyFromEnvironment,
132+
DialContext: (&net.Dialer{
133+
Timeout: 30 * time.Second,
134+
KeepAlive: 30 * time.Second,
135+
DualStack: false,
136+
}).DialContext,
137+
MaxIdleConns: 0,
138+
MaxIdleConnsPerHost: 32,
139+
IdleConnTimeout: 30 * time.Second,
140+
TLSHandshakeTimeout: 10 * time.Second,
141+
ExpectContinueTimeout: 5 * time.Second,
142+
DisableKeepAlives: true,
143+
}
144+
}
145+
128146
func init() {
129147
rootCmd.AddCommand(runCmd)
130148
}

0 commit comments

Comments
 (0)