Skip to content

Commit

Permalink
Use cleanhttp.DefaultPooledTransport for the default API client (#12409)
Browse files Browse the repository at this point in the history
The only difference is DefaultTransport sets DisableKeepAlives

This doesn't make much sense to me - every http connection from the
nomad client goes to the same NOMAD_ADDR so it's a great case for keep
alive. Except round robin DNS and anycast perhaps.

Consul does this already
https://github.com/hashicorp/consul/blob/1e47e3c82b6eb937baab0688a67cf7ef334ce42c/api/api.go#L397
  • Loading branch information
benbuzbee authored Apr 6, 2022
1 parent cf6ca95 commit 6e1270d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/12409.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
api: default to using DefaultPooledTransport client to support keep-alive by default
```
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (t *TLSConfig) Copy() *TLSConfig {
}

func defaultHttpClient() *http.Client {
httpClient := cleanhttp.DefaultClient()
httpClient := cleanhttp.DefaultPooledClient()
transport := httpClient.Transport.(*http.Transport)
transport.TLSHandshakeTimeout = 10 * time.Second
transport.TLSClientConfig = &tls.Config{
Expand Down

0 comments on commit 6e1270d

Please sign in to comment.