From 8c716920472b24d12d902770ea6120f2522aeb0e Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Thu, 6 Jun 2024 14:11:11 +0300 Subject: [PATCH] fix lint errors --- core/util/httputil/http_client_builder.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/util/httputil/http_client_builder.go b/core/util/httputil/http_client_builder.go index 2c24c5c..3e1a17b 100644 --- a/core/util/httputil/http_client_builder.go +++ b/core/util/httputil/http_client_builder.go @@ -17,6 +17,14 @@ import ( "github.com/retailcrm/mg-transport-core/v2/core/logger" ) +const ( + defaultDialerTimeout = 30 * time.Second + defaultIdleConnTimeout = 90 * time.Second + defaultTLSHandshakeTimeout = 10 * time.Second + defaultExpectContinueTimeout = 1 * time.Second + defaultMaxIdleConns = 100 +) + // DefaultClient stores original http.DefaultClient. var DefaultClient = http.DefaultClient @@ -71,17 +79,17 @@ func NewHTTPClientBuilder() *HTTPClientBuilder { httpTransport: &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, + Timeout: defaultDialerTimeout, + KeepAlive: defaultDialerTimeout, }).DialContext, ForceAttemptHTTP2: true, - MaxIdleConns: 100, - IdleConnTimeout: 90 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - ExpectContinueTimeout: 1 * time.Second, + MaxIdleConns: defaultMaxIdleConns, + IdleConnTimeout: defaultIdleConnTimeout, + TLSHandshakeTimeout: defaultTLSHandshakeTimeout, + ExpectContinueTimeout: defaultExpectContinueTimeout, }, tlsVersion: tls.VersionTLS12, - timeout: 30 * time.Second, + timeout: defaultDialerTimeout, mockAddress: "", mockedDomains: []string{}, logging: false,