mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
start to back off when we repeatedly receive a 429
This commit is contained in:
@@ -31,14 +31,8 @@ public class FeedRefreshIntervalCalculator {
|
|||||||
return onFetchSuccess(publishedDate, averageEntryInterval);
|
return onFetchSuccess(publishedDate, averageEntryInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant onTooManyRequests(Instant retryAfter) {
|
public Instant onTooManyRequests(Instant retryAfter, int errorCount) {
|
||||||
Instant defaultRefreshInterval = getDefaultRefreshInterval();
|
return ObjectUtils.max(retryAfter, onFetchError(errorCount));
|
||||||
|
|
||||||
if (retryAfter == null) {
|
|
||||||
return defaultRefreshInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ObjectUtils.max(retryAfter, defaultRefreshInterval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant onFetchError(int errorCount) {
|
public Instant onFetchError(int errorCount) {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class FeedRefreshWorker {
|
|||||||
|
|
||||||
feed.setErrorCount(feed.getErrorCount() + 1);
|
feed.setErrorCount(feed.getErrorCount() + 1);
|
||||||
feed.setMessage("Server indicated that we are sending too many requests");
|
feed.setMessage("Server indicated that we are sending too many requests");
|
||||||
feed.setDisabledUntil(refreshIntervalCalculator.onTooManyRequests(e.getRetryAfter()));
|
feed.setDisabledUntil(refreshIntervalCalculator.onTooManyRequests(e.getRetryAfter(), feed.getErrorCount()));
|
||||||
|
|
||||||
return new FeedRefreshWorkerResult(feed, Collections.emptyList());
|
return new FeedRefreshWorkerResult(feed, Collections.emptyList());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user