Skip to content

Commit

Permalink
feat: add retrying for failed http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
zzucch committed Sep 2, 2024
1 parent df1937c commit 69b08e8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,19 @@ func (c *Client) getResponse(url string, attempts int) (string, error) {

response, err := c.httpClient.Do(request)
if err != nil {
return "", err
if attempt < attempts-1 {
log.Warn(
"failed to do http request",
"url",
url,
"attempt",
attempt+1,
"err",
err)
continue
}

return "", err
}
defer response.Body.Close()

Expand Down

0 comments on commit 69b08e8

Please sign in to comment.