From d04b68979ae24c85639520ea6573d261d0f2cc81 Mon Sep 17 00:00:00 2001 From: TwiN Date: Mon, 26 Aug 2024 21:30:53 -0400 Subject: [PATCH] fix(remote): Stream endpoint statuses from remote instances instead of loading them all into memory --- api/endpoint_status.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/api/endpoint_status.go b/api/endpoint_status.go index 41627de2..b97eee11 100644 --- a/api/endpoint_status.go +++ b/api/endpoint_status.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "io" "log" "github.com/TwiN/gatus/v5/client" @@ -62,14 +61,8 @@ func getEndpointStatusesFromRemoteInstances(remoteConfig *remote.Config) ([]*end if err != nil { return nil, err } - body, err := io.ReadAll(response.Body) - if err != nil { - _ = response.Body.Close() - log.Printf("[api.getEndpointStatusesFromRemoteInstances] Silently failed to retrieve endpoint statuses from %s: %s", instance.URL, err.Error()) - continue - } var endpointStatuses []*endpoint.Status - if err = json.Unmarshal(body, &endpointStatuses); err != nil { + if err = json.NewDecoder(response.Body).Decode(&endpointStatuses); err != nil { _ = response.Body.Close() log.Printf("[api.getEndpointStatusesFromRemoteInstances] Silently failed to retrieve endpoint statuses from %s: %s", instance.URL, err.Error()) continue