mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
retry polic and circuit breaker policy
This commit is contained in:
@@ -21,6 +21,17 @@ public static class TorrentioInstancesExtensions
|
||||
|
||||
return remaining > TimeSpan.Zero ? remaining : TimeSpan.Zero;
|
||||
}
|
||||
|
||||
public static void SetPossiblyRateLimited(this TorrentioInstance instance, TorrentioScrapeInstance state, int minutesToWait = 5)
|
||||
{
|
||||
// Set the start time to 15 minutes in the past so that the next check will result in a rate limit period of 15 minutes
|
||||
var startedAt = DateTime.UtcNow.AddMinutes(-minutesToWait);
|
||||
var requestCount = instance.RateLimit.RequestLimit;
|
||||
|
||||
// Update the scraper state for the instance
|
||||
state.StartedAt = startedAt;
|
||||
state.RequestCount = requestCount;
|
||||
}
|
||||
|
||||
public static long TotalProcessedRequests(this TorrentioInstance instance, Dictionary<string, TorrentioScrapeInstance> scraperState) =>
|
||||
!scraperState.TryGetValue(instance.Name, out var state) ? 0 : state.TotalProcessed;
|
||||
|
||||
Reference in New Issue
Block a user