Session 20: Provider intelligence — quota tracker, gateway with fallback cascade, admin quota dashboard (1476 tests)

This commit is contained in:
Kev
2026-06-12 00:54:39 -04:00
parent 56392ec8f4
commit 9b10bb4138
17 changed files with 1422 additions and 15 deletions
+19
View File
@@ -155,6 +155,25 @@ async function tick() {
const summary = [];
let liveSeen = false;
// Session 20 — skip ticks entirely when football-data quota is
// exhausted. The poller's fixture fetcher hits the football-data
// adapter for any non-WC league; firing every minute against a
// 10-req/min limit blows the budget. The tracker's per-minute
// window auto-resets so the next minute's tick will fire.
try {
const quotaTracker = require('../src/services/quotaTracker');
const { allowed, interval } = await quotaTracker.shouldThrottle('football-data');
if (!allowed || interval === null) {
console.log('[poller-soccer] tick skipped — football-data quota exhausted');
return { liveSeen: false, summary: ['quota_exhausted'] };
}
} catch (e) {
// Tracker is best-effort. If it crashes (Redis hiccup) we
// proceed — the underlying adapters will surface their own
// 429s and the gateway's degraded-mode fail-open kicks in.
console.warn('[poller-soccer] quotaTracker check failed:', e.message);
}
for (const league of leagues) {
const fixtures = await fetchLeagueFixtures(league);
if (fixtures === null) {