start to back off when we repeatedly receive a 429

This commit is contained in:
Athou
2025-02-12 07:59:52 +01:00
parent bf6c2d7beb
commit bde556d41f
2 changed files with 3 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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) {