Improved handling of errors and included manual refreshing
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
@@ -23,7 +23,7 @@ func New(cookie string) *HTTPClient {
|
||||
Cookie: cookie,
|
||||
|
||||
client: &http.Client{},
|
||||
rl: rate.NewLimiter(rate.Every(1*time.Second), 15),
|
||||
rl: rate.NewLimiter(rate.Every(1*time.Second), 10),
|
||||
ctx: context.Background(),
|
||||
retries: 3,
|
||||
}
|
||||
@@ -52,7 +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)
|
||||
time.Sleep(15 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user