fix: usage of method `GetFastHttpClient` (#62)

This commit is contained in:
silenceqi 2024-12-30 11:05:29 +08:00 committed by GitHub
parent 29bef5e129
commit 9733b72531
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -117,7 +117,8 @@ func (h TestAPI) HandleTestConnectionAction(w http.ResponseWriter, req *http.Req
freq.SetBasicAuth(config.BasicAuth.Username, config.BasicAuth.Password.Get()) freq.SetBasicAuth(config.BasicAuth.Username, config.BasicAuth.Password.Get())
} }
err = api.GetFastHttpClient("elasticsearch_test_connection").DoTimeout(freq, fres, 10*time.Second) const testClientName = "elasticsearch_test_connection"
err = api.GetFastHttpClient(testClientName).DoTimeout(freq, fres, 10*time.Second)
if err != nil { if err != nil {
panic(err) panic(err)
@ -145,7 +146,7 @@ func (h TestAPI) HandleTestConnectionAction(w http.ResponseWriter, req *http.Req
//fetch cluster health info //fetch cluster health info
freq.SetRequestURI(fmt.Sprintf("%s/_cluster/health", config.Endpoint)) freq.SetRequestURI(fmt.Sprintf("%s/_cluster/health", config.Endpoint))
fres.Reset() fres.Reset()
err = api.GetFastHttpClient().Do(freq, fres) err = api.GetFastHttpClient(testClientName).Do(freq, fres)
if err != nil { if err != nil {
resBody["error"] = fmt.Sprintf("error on get cluster health: %v", err) resBody["error"] = fmt.Sprintf("error on get cluster health: %v", err)
h.WriteJSON(w, resBody, http.StatusInternalServerError) h.WriteJSON(w, resBody, http.StatusInternalServerError)