Improved retries
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
@@ -110,7 +110,7 @@ func GetLatestBooks() (map[string]*Book, error) {
|
|||||||
func getRating(bookID string) string {
|
func getRating(bookID string) string {
|
||||||
resp, err := c.Get(fmt.Sprintf("https://app.thestorygraph.com/books/%s/community_reviews", bookID))
|
resp, err := c.Get(fmt.Sprintf("https://app.thestorygraph.com/books/%s/community_reviews", bookID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error fetching book rating:", resp.StatusCode)
|
fmt.Println("Error fetching book rating:", err)
|
||||||
return "0.0"
|
return "0.0"
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ func (h *HTTPClient) Get(url string) (*http.Response, error) {
|
|||||||
if resp.StatusCode == 429 {
|
if resp.StatusCode == 429 {
|
||||||
fmt.Println("Rate limit exceeded, retrying...")
|
fmt.Println("Rate limit exceeded, retrying...")
|
||||||
h.retries--
|
h.retries--
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user