Skip to content

Commit

Permalink
utils: let http client can reuse connections (#6914) (#6916)
Browse files Browse the repository at this point in the history
close #6913

utils: let HTTP client can reuse connections

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: nolouch <nolouch@gmail.com>

Co-authored-by: ShuNing <nolouch@gmail.com>
Co-authored-by: nolouch <nolouch@gmail.com>
  • Loading branch information
ti-chi-bot and nolouch authored Aug 9, 2023
1 parent f2b53f4 commit adf0402
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,16 @@ func (s *Server) startEtcd(ctx context.Context) error {
}
}
s.client = client
s.httpClient = &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.
httpCli := &http.Client{}
if tlsConfig != nil {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = tlsConfig
httpCli.Transport = transport
}
s.httpClient = httpCli

failpoint.Inject("memberNil", func() {
time.Sleep(1500 * time.Millisecond)
Expand Down

0 comments on commit adf0402

Please sign in to comment.