forked from Archives/Athou_commafeed
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);
|
||||
}
|
||||
|
||||
public Instant onTooManyRequests(Instant retryAfter) {
|
||||
Instant defaultRefreshInterval = getDefaultRefreshInterval();
|
||||
|
||||
if (retryAfter == null) {
|
||||
return defaultRefreshInterval;
|
||||
}
|
||||
|
||||
return ObjectUtils.max(retryAfter, defaultRefreshInterval);
|
||||
public Instant onTooManyRequests(Instant retryAfter, int errorCount) {
|
||||
return ObjectUtils.max(retryAfter, onFetchError(errorCount));
|
||||
}
|
||||
|
||||
public Instant onFetchError(int errorCount) {
|
||||
|
||||
@@ -104,7 +104,7 @@ public class FeedRefreshWorker {
|
||||
|
||||
feed.setErrorCount(feed.getErrorCount() + 1);
|
||||
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());
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user