Skip to content

Commit 1e85039

Browse files
committed
Reuse http client
1 parent efb6ece commit 1e85039

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

enterprise/replicasync/replicasync.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ func (m *Manager) syncReplicas(ctx context.Context) error {
219219
}
220220
m.mutex.Unlock()
221221

222+
client := http.Client{
223+
Timeout: m.options.PeerTimeout,
224+
Transport: &http.Transport{
225+
TLSClientConfig: m.options.TLSConfig,
226+
},
227+
}
228+
defer client.CloseIdleConnections()
222229
var wg sync.WaitGroup
223230
var mu sync.Mutex
224231
failed := make([]string, 0)
@@ -232,12 +239,6 @@ func (m *Manager) syncReplicas(ctx context.Context) error {
232239
slog.F("relay_address", peer.RelayAddress), slog.Error(err))
233240
return
234241
}
235-
client := http.Client{
236-
Timeout: m.options.PeerTimeout,
237-
Transport: &http.Transport{
238-
TLSClientConfig: m.options.TLSConfig,
239-
},
240-
}
241242
res, err := client.Do(req)
242243
if err != nil {
243244
mu.Lock()

0 commit comments

Comments
 (0)