mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
fix: fetch span retry bug
This commit is contained in:
parent
2321e64ed7
commit
e4e5d4a0c1
1 changed files with 13 additions and 1 deletions
|
|
@ -99,6 +99,17 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
|
|||
u.Path = rawPath
|
||||
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
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
|
@ -113,7 +124,8 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
|
|||
if err == nil && 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++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue