From eca9a4f49afc84adadf49dca4003f0c1ac202b6b Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Tue, 23 Jan 2024 02:46:11 +0100 Subject: [PATCH] Set max connections to 32 --- pkg/http/client.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/http/client.go b/pkg/http/client.go index bd9682f..2b73621 100644 --- a/pkg/http/client.go +++ b/pkg/http/client.go @@ -124,6 +124,11 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host } } + maxConnections := cfg.GetNumOfWorkers() + if maxConnections > 32 { + maxConnections = 32 + } + if cfg.ShouldForceIPv6() { ipv6List, err := hosts.FetchHosts(hosts.IPV6) if err != nil { @@ -135,6 +140,8 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host } client.client.Transport = &http.Transport{ + MaxIdleConns: maxConnections, + MaxConnsPerHost: maxConnections, DialContext: func(ctx context.Context, network, address string) (net.Conn, error) { if ipv6Address, ok := client.ipv6.Get(address); ok { return dialer.Dial(network, ipv6Address) @@ -159,6 +166,8 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host } } else { client.client.Transport = &http.Transport{ + MaxIdleConns: maxConnections, + MaxConnsPerHost: maxConnections, DialContext: func(ctx context.Context, network, address string) (net.Conn, error) { return dialer.Dial(network, address) },