@@ -22,6 +22,7 @@ import (
2222 "os"
2323 "runtime"
2424 "strings"
25+ "time"
2526 "unicode"
2627
2728 "google.golang.org/grpc"
@@ -33,6 +34,26 @@ import (
3334 "github.com/dolthub/dolt/go/libraries/doltcore/grpcendpoint"
3435)
3536
37+ var defaultDialer = & net.Dialer {
38+ Timeout : 30 * time .Second ,
39+ KeepAlive : 30 * time .Second ,
40+ }
41+
42+ var defaultTransport = & http.Transport {
43+ Proxy : http .ProxyFromEnvironment ,
44+ DialContext : defaultDialer .DialContext ,
45+ ForceAttemptHTTP2 : true ,
46+ MaxIdleConns : 1024 ,
47+ MaxIdleConnsPerHost : 256 ,
48+ IdleConnTimeout : 90 * time .Second ,
49+ TLSHandshakeTimeout : 10 * time .Second ,
50+ ExpectContinueTimeout : 1 * time .Second ,
51+ }
52+
53+ var defaultHttpFetcher grpcendpoint.HTTPFetcher = & http.Client {
54+ Transport : defaultTransport ,
55+ }
56+
3657// GRPCDialProvider implements dbfactory.GRPCDialProvider. By default, it is not able to use custom user credentials, but
3758// if it is initialized with a DoltEnv, it will load custom user credentials from it.
3859type GRPCDialProvider struct {
@@ -66,18 +87,26 @@ func (p GRPCDialProvider) GetGRPCDialParams(config grpcendpoint.Config) (dbfacto
6687 }
6788 }
6889
69- var httpfetcher grpcendpoint.HTTPFetcher = http . DefaultClient
90+ var httpfetcher grpcendpoint.HTTPFetcher = defaultHttpFetcher
7091
7192 var opts []grpc.DialOption
7293 if config .TLSConfig != nil {
7394 tc := credentials .NewTLS (config .TLSConfig )
7495 opts = append (opts , grpc .WithTransportCredentials (tc ))
7596
97+ transport := & http.Transport {
98+ Proxy : http .ProxyFromEnvironment ,
99+ DialContext : defaultDialer .DialContext ,
100+ ForceAttemptHTTP2 : true ,
101+ MaxIdleConns : 1024 ,
102+ MaxIdleConnsPerHost : 256 ,
103+ IdleConnTimeout : 90 * time .Second ,
104+ TLSClientConfig : config .TLSConfig ,
105+ TLSHandshakeTimeout : 10 * time .Second ,
106+ ExpectContinueTimeout : 1 * time .Second ,
107+ }
76108 httpfetcher = & http.Client {
77- Transport : & http.Transport {
78- TLSClientConfig : config .TLSConfig ,
79- ForceAttemptHTTP2 : true ,
80- },
109+ Transport : transport ,
81110 }
82111 } else if config .Insecure {
83112 opts = append (opts , grpc .WithInsecure ())
@@ -109,6 +138,7 @@ func (p GRPCDialProvider) GetGRPCDialParams(config grpcendpoint.Config) (dbfacto
109138 opts = append (opts , grpc .WithPerRPCCredentials (rpcCreds ))
110139 }
111140 }
141+
112142 return dbfactory.GRPCRemoteConfig {
113143 Endpoint : endpoint ,
114144 DialOptions : opts ,
0 commit comments