explicitly use http2

This commit is contained in:
Andre Medeiros 2022-11-02 19:05:23 -04:00
parent c6903d2b5f
commit 164652e2e4

View file

@ -2,7 +2,6 @@ package reddit
import ( import (
"context" "context"
"crypto/tls"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -15,6 +14,7 @@ import (
"github.com/DataDog/datadog-go/statsd" "github.com/DataDog/datadog-go/statsd"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"github.com/valyala/fastjson" "github.com/valyala/fastjson"
"golang.org/x/net/http2"
) )
const ( const (
@ -96,11 +96,10 @@ func NewClient(id, secret string, statsd statsd.ClientInterface, redis *redis.Cl
}, },
} }
t := http.DefaultTransport.(*http.Transport).Clone() t := &http2.Transport{
t.MaxIdleConns = connLimit / 2 //TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // TODO(andremedeiros): remove
t.MaxConnsPerHost = connLimit }
t.MaxIdleConnsPerHost = 100
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} // TODO(andremedeiros): remove
client := &http.Client{ client := &http.Client{
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
Transport: t, Transport: t,