From fa72756aafc48413070cc5b095c49dca8ba6e5b0 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Wed, 7 May 2025 06:37:59 +0100 Subject: [PATCH] Improved retries Signed-off-by: Marcus Noble --- pkg/storygraph/client.go | 2 +- pkg/storygraph/http.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/storygraph/client.go b/pkg/storygraph/client.go index 5bc4393..79dc232 100644 --- a/pkg/storygraph/client.go +++ b/pkg/storygraph/client.go @@ -110,7 +110,7 @@ func GetLatestBooks() (map[string]*Book, error) { func getRating(bookID string) string { resp, err := c.Get(fmt.Sprintf("https://app.thestorygraph.com/books/%s/community_reviews", bookID)) if err != nil { - fmt.Println("Error fetching book rating:", resp.StatusCode) + fmt.Println("Error fetching book rating:", err) return "0.0" } defer resp.Body.Close() diff --git a/pkg/storygraph/http.go b/pkg/storygraph/http.go index 2c0ea07..4c1f55f 100644 --- a/pkg/storygraph/http.go +++ b/pkg/storygraph/http.go @@ -52,6 +52,7 @@ func (h *HTTPClient) Get(url string) (*http.Response, error) { if resp.StatusCode == 429 { fmt.Println("Rate limit exceeded, retrying...") h.retries-- + time.Sleep(30 * time.Second) continue }