From edd74d1142a5ac9fb13f0acd7781641e4bc71277 Mon Sep 17 00:00:00 2001 From: Intizar Date: Wed, 28 Aug 2024 16:06:33 +0900 Subject: [PATCH] fetch latest data rest with timeout --- node/pkg/reporter/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/pkg/reporter/utils.go b/node/pkg/reporter/utils.go index ed1949eb9..0d48ed992 100644 --- a/node/pkg/reporter/utils.go +++ b/node/pkg/reporter/utils.go @@ -43,7 +43,11 @@ func GetDeviatingAggregates(latestSubmittedData *sync.Map, latestData *sync.Map, func GetLatestDataRest(ctx context.Context, name []string) (map[string]SubmissionData, error) { url := fmt.Sprintf("http://orakl-dal.orakl.svc.cluster.local/latest-data-feeds/%s", strings.Join(name, ",")) - resp, err := request.Request[[]RawSubmissionData](request.WithEndpoint(url), request.WithHeaders(map[string]string{"X-API-Key": secrets.GetSecret("API_KEY")})) + resp, err := request.Request[[]RawSubmissionData]( + request.WithEndpoint(url), + request.WithHeaders(map[string]string{"X-API-Key": secrets.GetSecret("API_KEY")}), + request.WithTimeout(5*time.Second), // data will be too old if it takes too long to fetch + ) if err != nil { return nil, err }