MSP-8995 up golangci-lint config and fix lint issues

This commit is contained in:
bogdanmezencev committed 2026-11-18 19:52:40 +03:00
1 parent 80d9286498
commit 5191f45076
9 files changed
+62 -31

No files matched your search

+1
View File
@@ -32,6 +32,7 @@ func init() {
}
}
//nolint:gochecknoglobals
var (
codeMap = map[int]codes.Code{
http.StatusOK: codes.OK,
+21 -10
View File
@@ -20,21 +20,30 @@ import (
"github.com/txix-open/isp-kit/requestid"
)
var (
httpTransport = &http.Transport{
const (
httpDialTimeout = 3 * time.Second
httpDialKeepAlive = 30 * time.Second
httpMaxIdleConns = 512
httpMaxIdleConnsPerHost = 32
httpIdleConnTimeout = 60 * time.Second
httpTLSHandshakeTimeout = 5 * time.Second
)
func newHttpTransport() *http.Transport {
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: defaultTransportDialContext(&net.Dialer{
Timeout: 3 * time.Second,
KeepAlive: 30 * time.Second,
Timeout: httpDialTimeout,
KeepAlive: httpDialKeepAlive,
}),
ForceAttemptHTTP2: true,
MaxIdleConns: 512,
MaxIdleConnsPerHost: 32,
IdleConnTimeout: 60 * time.Second,
TLSHandshakeTimeout: 5 * time.Second,
MaxIdleConns: httpMaxIdleConns,
MaxIdleConnsPerHost: httpMaxIdleConnsPerHost,
IdleConnTimeout: httpIdleConnTimeout,
TLSHandshakeTimeout: httpTLSHandshakeTimeout,
ExpectContinueTimeout: 1 * time.Second,
}
)
}
type HttpHostManager interface {
Next() (string, error)
@@ -42,6 +51,7 @@ type HttpHostManager interface {
type Http struct {
hostManager HttpHostManager
transport http.RoundTripper
skipAuth bool
timeout time.Duration
}
@@ -49,6 +59,7 @@ type Http struct {
func NewHttp(hostManager HttpHostManager, skipAuth bool, timeout time.Duration) Http {
return Http{
hostManager: hostManager,
transport: newHttpTransport(),
skipAuth: skipAuth,
timeout: timeout,
}
@@ -71,7 +82,7 @@ func (p Http) Handle(ctx *request.Context) error {
setHttpHeaders(ctx, request.Header, p.skipAuth)
reverseProxy := httputil.NewSingleHostReverseProxy(target)
reverseProxy.Transport = httpTransport
reverseProxy.Transport = p.transport
var resultError error
reverseProxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, err error) {
resultError = httperrors.New(
+9 -3
View File
@@ -13,6 +13,12 @@ import (
"isp-gate-service/request"
)
const (
wsHandshakeTimeout = 5 * time.Second
wsReadBufferSize = 1024
wsWriteBufferSize = 1024
)
type Ws struct {
hostManager HttpHostManager
skipAuth bool
@@ -46,9 +52,9 @@ func (ws Ws) Handle(ctx *request.Context) error {
setHttpHeaders(ctx, out, ws.skipAuth)
}
proxy.Upgrader = &websocket.Upgrader{
HandshakeTimeout: 5 * time.Second,
ReadBufferSize: 1024,
WriteBufferSize: 1024,
HandshakeTimeout: wsHandshakeTimeout,
ReadBufferSize: wsReadBufferSize,
WriteBufferSize: wsWriteBufferSize,
WriteBufferPool: nil,
Subprotocols: nil,
Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) {