|
5 | 5 | "context" |
6 | 6 | "fmt" |
7 | 7 | "io" |
| 8 | + "net" |
8 | 9 | "net/http" |
9 | 10 | "net/url" |
10 | 11 | "strconv" |
@@ -93,9 +94,43 @@ func New(path Route, conf *config.Config, log logger.Logger, stats stats.Stats) |
93 | 94 | reportingServiceURL := conf.GetString("REPORTING_URL", "https://reporting.dev.rudderlabs.com") |
94 | 95 | reportingServiceURL = strings.TrimSuffix(reportingServiceURL, "/") |
95 | 96 |
|
| 97 | + transport := http.DefaultTransport.(*http.Transport).Clone() |
| 98 | + |
| 99 | + if conf.IsSet("Reporting.httpClient.transport.maxIdleConns") { |
| 100 | + transport.MaxIdleConns = conf.GetInt("Reporting.httpClient.transport.maxIdleConns", 100) |
| 101 | + } |
| 102 | + |
| 103 | + if conf.IsSet("Reporting.httpClient.transport.idleConnTimeout") { |
| 104 | + transport.IdleConnTimeout = conf.GetDurationVar(90, time.Second, "Reporting.httpClient.transport.idleConnTimeout") |
| 105 | + } |
| 106 | + |
| 107 | + if conf.IsSet("Reporting.httpClient.transport.tlsHandshakeTimeout") { |
| 108 | + transport.TLSHandshakeTimeout = conf.GetDurationVar(10, time.Second, "Reporting.httpClient.transport.tlsHandshakeTimeout") |
| 109 | + } |
| 110 | + |
| 111 | + if conf.IsSet("Reporting.httpClient.transport.disableKeepAlives") { |
| 112 | + transport.DisableKeepAlives = conf.GetBool("Reporting.httpClient.transport.disableKeepAlives", false) |
| 113 | + } |
| 114 | + |
| 115 | + if conf.IsSet("Reporting.httpClient.transport.dialer.timeout") { |
| 116 | + transport.DialContext = (&net.Dialer{ |
| 117 | + Timeout: conf.GetDurationVar(30, time.Second, "Reporting.httpClient.transport.dialer.timeout"), |
| 118 | + KeepAlive: conf.GetDurationVar(30, time.Second, "Reporting.httpClient.transport.dialer.keepAlive"), |
| 119 | + }).DialContext |
| 120 | + } |
| 121 | + |
| 122 | + if conf.IsSet("Reporting.httpClient.transport.forceAttemptHTTP2") { |
| 123 | + transport.ForceAttemptHTTP2 = conf.GetBool("Reporting.httpClient.transport.forceAttemptHTTP2", true) |
| 124 | + } |
| 125 | + |
| 126 | + if conf.IsSet("Reporting.httpClient.transport.expectContinueTimeout") { |
| 127 | + transport.ExpectContinueTimeout = conf.GetDurationVar(1, time.Second, "Reporting.httpClient.transport.expectContinueTimeout") |
| 128 | + } |
| 129 | + |
96 | 130 | return &Client{ |
97 | 131 | httpClient: &http.Client{ |
98 | | - Timeout: conf.GetDurationVar(60, time.Second, "Reporting.httpClient.timeout", "HttpClient.reporting.timeout"), |
| 132 | + Timeout: conf.GetDurationVar(60, time.Second, "Reporting.httpClient.timeout", "HttpClient.reporting.timeout"), |
| 133 | + Transport: transport, |
99 | 134 | }, |
100 | 135 | reportingServiceURL: reportingServiceURL, |
101 | 136 | backoff: backOffFromConfig(conf), |
|
0 commit comments