api: use cleanhttp.DefaultPooledTransport for default API client (#12492)

We expect every Nomad API client to use a single connection to any
given agent, so take advantage of keep-alive by switching the default
transport to `DefaultPooledClient`. Provide a facility to close idle
connections for testing purposes.

Restores the previously reverted #12409


Co-authored-by: Ben Buzbee <bbuzbee@cloudflare.com>
This commit is contained in:
Tim Gross
2022-04-06 16:14:53 -04:00
committed by GitHub
parent fb6da72a25
commit daa982425e
3 changed files with 18 additions and 1 deletions

View File

@@ -1113,6 +1113,8 @@ func TestHTTPServer_Limits_OK(t *testing.T) {
conf.Address = a.HTTPAddr()
conf.TLSConfig.Insecure = true
client, err := api.NewClient(conf)
defer client.Close()
require.NoError(t, err)
// Assert a blocking query isn't timed out by the