fix: fetch span retry bug

This commit is contained in:
Manav Darji 2022-05-10 19:00:10 +05:30 committed by Victor Castell
parent 2321e64ed7
commit e4e5d4a0c1

View file

@ -99,6 +99,17 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
u.Path = rawPath u.Path = rawPath
u.RawQuery = rawQuery u.RawQuery = rawQuery
// attempt counter
attempt := 1
// request data once
res, err := h.internalFetch(u)
if err == nil && res != nil {
return res, nil
}
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path, "attempt", attempt)
attempt++
// create a new ticker for retrying the request // create a new ticker for retrying the request
ticker := time.NewTicker(5 * time.Second) ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop() defer ticker.Stop()
@ -113,7 +124,8 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
if err == nil && res != nil { if err == nil && res != nil {
return res, nil return res, nil
} }
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path) log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path, "attempt", attempt)
attempt++
} }
} }
} }