mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Added RateLimit service to globally manager short duration ratelimits.
This commit is contained in:
@@ -6,6 +6,7 @@ using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.TPL;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
@@ -27,6 +28,7 @@ namespace NzbDrone.Core.Indexers
|
||||
public bool SupportsPaging { get { return PageSize > 0; } }
|
||||
|
||||
public virtual Int32 PageSize { get { return 0; } }
|
||||
public virtual TimeSpan RateLimit { get { return TimeSpan.FromSeconds(2); } }
|
||||
|
||||
public abstract IIndexerRequestGenerator GetRequestGenerator();
|
||||
public abstract IParseIndexerResponse GetParser();
|
||||
@@ -199,6 +201,11 @@ namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
_logger.Debug("Downloading Feed " + request.Url);
|
||||
|
||||
if (request.HttpRequest.RateLimit < RateLimit)
|
||||
{
|
||||
request.HttpRequest.RateLimit = RateLimit;
|
||||
}
|
||||
|
||||
return new IndexerResponse(request, _httpClient.Execute(request.HttpRequest));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user