Skip to content
Snippets Groups Projects
Commit f6567816 authored by ale's avatar ale
Browse files

Minor fix to google books ratelimit response

parent a5e06fb5
No related branches found
No related tags found
No related merge requests found
......@@ -126,9 +126,11 @@ func googleBooksGet(uri string) (*http.Response, error) {
<-gbSemaphore
}()
// Set a deadline to 1 hour.
// Set a deadline to 10 minutes.
timeout := 900 * time.Second
backoff := 500 * time.Millisecond
deadline := time.Now().Add(3600 * time.Second)
maxBackoff := 60 * time.Second
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
resp, err := http.Get(uri)
if err != nil {
......@@ -140,6 +142,9 @@ func googleBooksGet(uri string) (*http.Response, error) {
resp.Body.Close()
time.Sleep(backoff)
backoff += backoff / 2
if backoff > maxBackoff {
backoff = maxBackoff
}
continue
case 200:
return resp, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment