From 902574e5017f7a2f36fd86b79a6fd6523d581eea Mon Sep 17 00:00:00 2001 From: Stavros Date: Fri, 19 Sep 2025 14:39:24 +0300 Subject: [PATCH] refactor: don't create new client everytime --- internal/bootstrap/app_bootstrap.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/bootstrap/app_bootstrap.go b/internal/bootstrap/app_bootstrap.go index 1a527b5..d1f3373 100644 --- a/internal/bootstrap/app_bootstrap.go +++ b/internal/bootstrap/app_bootstrap.go @@ -1,6 +1,7 @@ package bootstrap import ( + "bytes" "encoding/json" "fmt" "net/http" @@ -307,12 +308,14 @@ func (app *BootstrapApp) heartbeat() { return } + client := &http.Client{} + heartbeatURL := config.ApiServer + "/v1/instances/heartbeat" for ; true; <-ticker.C { log.Debug().Msg("Sending heartbeat") - req, err := http.NewRequest(http.MethodPost, heartbeatURL, strings.NewReader(string(bodyJson))) + req, err := http.NewRequest(http.MethodPost, heartbeatURL, bytes.NewReader(bodyJson)) if err != nil { log.Error().Err(err).Msg("Failed to create heartbeat request") @@ -321,8 +324,6 @@ func (app *BootstrapApp) heartbeat() { req.Header.Add("Content-Type", "application/json") - client := &http.Client{} - res, err := client.Do(req) if err != nil {