Skip to content

Commit

Permalink
utils: let http client can reuse connections (tikv#7048)
Browse files Browse the repository at this point in the history
 

Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp authored Sep 7, 2023
1 parent f8bf1d7 commit 5693f7b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/utils/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,16 @@ func CreateEtcdClient(tlsConfig *tls.Config, acURL url.URL) (*clientv3.Client, e
}

func createHTTPClient(tlsConfig *tls.Config) *http.Client {
return &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
TLSClientConfig: tlsConfig,
},
// FIXME: Currently, there is no timeout set for certain requests, such as GetRegions,
// which may take a significant amount of time. However, it might be necessary to
// define an appropriate timeout in the future.
cli := &http.Client{}
if tlsConfig != nil {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = tlsConfig
cli.Transport = transport
}
return cli
}

// InitClusterID creates a cluster ID for the given key if it hasn't existed.
Expand Down

0 comments on commit 5693f7b

Please sign in to comment.