Rarbg Rate Limit Tweaks, Additional back-off level

pull/1279/head
Qstick 2 years ago
parent de2fd92b6f
commit 5cc044aa8f

@ -107,7 +107,6 @@ namespace NzbDrone.Core.Indexers.Rarbg
var response = await FetchIndexerResponse(request);
// try and recover from token errors
// Response of 200 and rate_limt of 1 requires a 5 minute backoff. Handle in Response Parsing & do not page further if rate_limit is populated.
var jsonResponse = new HttpResponse<RarbgResponse>(response.HttpResponse);
if (jsonResponse.Resource.error_code.HasValue)
@ -126,7 +125,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
}
else if (jsonResponse.Resource.error_code == 5)
{
_logger.Debug("Rarbg temp rate limit hit, retying request");
_logger.Debug("Rarbg temp rate limit hit, retrying request");
response = await FetchIndexerResponse(request);
}
}

@ -23,19 +23,15 @@ namespace NzbDrone.Core.Indexers.Rarbg
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
{
var results = new List<ReleaseInfo>();
var retryTime = TimeSpan.FromMinutes(1);
var responseCode = (int)indexerResponse.HttpResponse.StatusCode;
switch (responseCode)
{
case (int)HttpStatusCode.TooManyRequests:
retryTime = TimeSpan.FromMinutes(2);
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime);
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, TimeSpan.FromMinutes(2));
case 520:
retryTime = TimeSpan.FromMinutes(3);
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime);
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, TimeSpan.FromMinutes(3));
case (int)HttpStatusCode.OK:
retryTime = TimeSpan.FromMinutes(5);
break;
default:
throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", responseCode);
@ -43,12 +39,6 @@ namespace NzbDrone.Core.Indexers.Rarbg
var jsonResponse = new HttpResponse<RarbgResponse>(indexerResponse.HttpResponse);
// Handle 200 Rate Limiting
if (jsonResponse.Resource.rate_limit == 1)
{
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime);
}
if (jsonResponse.Resource.error_code.HasValue)
{
if (jsonResponse.Resource.error_code == 20 || jsonResponse.Resource.error_code == 8

@ -1,10 +1,11 @@
namespace NzbDrone.Core.ThingiProvider.Status
namespace NzbDrone.Core.ThingiProvider.Status
{
public static class EscalationBackOff
{
public static readonly int[] Periods =
{
0,
60,
5 * 60,
15 * 60,
30 * 60,

Loading…
Cancel
Save