Add retry debug messages
This commit is contained in:
@@ -260,30 +260,29 @@ func (r *HTTPClient) shouldRetry(req *http.Request, resp *http.Response, err err
|
||||
case 5: // Slow down (retry infinitely)
|
||||
case 34: // Too many requests (retry infinitely)
|
||||
secs := r.backoff(attempts, rateLimitSleep)
|
||||
r.log.Warnf("API rate limit reached, retrying in %d seconds", secs/time.Second)
|
||||
r.log.Debugf("API rate limit reached, retrying in %d seconds", secs/time.Second)
|
||||
time.Sleep(secs)
|
||||
return 0
|
||||
case 36: // Fair Usage Limit
|
||||
secs := r.backoff(attempts, rateLimitSleep)
|
||||
r.log.Warnf("Fair usage limit reached, retrying in %d seconds", secs/time.Second)
|
||||
r.log.Debugf("Fair usage limit reached, retrying in %d seconds", secs/time.Second)
|
||||
time.Sleep(secs)
|
||||
return 0
|
||||
case -1: // Internal error
|
||||
r.log.Debugf("RD Internal error, attempt #%d, retrying", attempts+1)
|
||||
return 1
|
||||
default:
|
||||
return -1
|
||||
}
|
||||
} else if downloadErr, ok := err.(*DownloadErrorResponse); ok {
|
||||
switch downloadErr.Message {
|
||||
case "bytes_limit_reached": // 503
|
||||
return -1
|
||||
case "invalid_download_code": // 404
|
||||
secs := r.backoff(attempts, rateLimitSleep)
|
||||
r.log.Warnf("Invalid download code, retrying in %d seconds", secs/time.Second)
|
||||
r.log.Debugf("Invalid download code, attempt #%d, retrying in %d seconds", attempts+1, secs/time.Second)
|
||||
time.Sleep(r.backoff(attempts, rateLimitSleep))
|
||||
return 1
|
||||
default:
|
||||
return 1 // retry
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,12 +292,12 @@ func (r *HTTPClient) shouldRetry(req *http.Request, resp *http.Response, err err
|
||||
// if the request has a Range header but the server doesn't respond with a Content-Range header
|
||||
hasRangeHeader := req.Header.Get("Range") != "" && !strings.HasPrefix(req.Header.Get("Range"), "bytes=0-")
|
||||
if okResponseCode && hasRangeHeader && resp.Header.Get("Content-Range") == "" {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
return 0
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
r.log.Debugf("Request failed, attempt #%d, retrying (error=%v)", attempts+1, err)
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user