Set max connections to 32
This commit is contained in:
@@ -124,6 +124,11 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxConnections := cfg.GetNumOfWorkers()
|
||||||
|
if maxConnections > 32 {
|
||||||
|
maxConnections = 32
|
||||||
|
}
|
||||||
|
|
||||||
if cfg.ShouldForceIPv6() {
|
if cfg.ShouldForceIPv6() {
|
||||||
ipv6List, err := hosts.FetchHosts(hosts.IPV6)
|
ipv6List, err := hosts.FetchHosts(hosts.IPV6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -135,6 +140,8 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.client.Transport = &http.Transport{
|
client.client.Transport = &http.Transport{
|
||||||
|
MaxIdleConns: maxConnections,
|
||||||
|
MaxConnsPerHost: maxConnections,
|
||||||
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
if ipv6Address, ok := client.ipv6.Get(address); ok {
|
if ipv6Address, ok := client.ipv6.Get(address); ok {
|
||||||
return dialer.Dial(network, ipv6Address)
|
return dialer.Dial(network, ipv6Address)
|
||||||
@@ -159,6 +166,8 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
client.client.Transport = &http.Transport{
|
client.client.Transport = &http.Transport{
|
||||||
|
MaxIdleConns: maxConnections,
|
||||||
|
MaxConnsPerHost: maxConnections,
|
||||||
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
return dialer.Dial(network, address)
|
return dialer.Dial(network, address)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user