/** * @fileoverview Outbound pacer shared by every GDELT API call (DOC and TV) — one request * in flight, spaced from the previous response's completion, behind a cooldown gate that an * upstream rate limit closes for every queued caller at once. * @module services/gdelt/gdelt-pacer */ import { type Pacer } from '@cyanheads/mcp-ts-core/utils'; /** * Wait budget for one queued caller. Deliberately above {@link GDELT_COOLDOWN_MAX_MS} plus a * request gap: matched to the ceiling, a caller shed by the budget timer is shed at the exact * instant the gate reopens, so it can never wait out a closed gate *and* reach a slot. It stays * below the per-call deadline (twice `GDELT_REQUEST_TIMEOUT_MS`), so a caller queued behind one * full retry ladder is shed rather than parked. A shed spends no upstream request. */ export declare const GDELT_MAX_QUEUE_WAIT_MS = 90000; /** * Build the process-wide GDELT pacer. `minStartGapMs` is the configured * `GDELT_REQUEST_DELAY_MS`; `maxConcurrent: 1` keeps a single request in flight so a slow * response never overlaps the next one. */ export declare function initGdeltPacer(minStartGapMs: number): void; export declare function getGdeltPacer(): Pacer; /** * Record that an upstream request settled — success or failure alike, since a rejection spends * the slot just as a response does. Read by {@link holdForGdeltRequestGap}. */ export declare function recordGdeltRequestSettled(): void; /** * Hold until a full request gap has elapsed since the previous request settled. * * `createPacer` spaces consecutive *starts*: with one request in flight the next start is * `max(previous start + gap, previous completion)`, so any response slower than the gap leaves * no gap at all after it completes — the normal case against an API that answers in tens of * seconds. GDELT's limiter counts from completion, so the hold has to live on this side of the * pacer. It runs before the fetch rather than after it, so a caller's own result is never * delayed, and `maxConcurrent: 1` means nothing else can start during it. * * Rejects with the signal's reason if the caller goes away mid-hold. */ export declare function holdForGdeltRequestGap(signal: AbortSignal): Promise; /** Release the pacer's timer and reject every queued waiter. Wired to `createApp({ teardown })`. */ export declare function disposeGdeltPacer(): void; //# sourceMappingURL=gdelt-pacer.d.ts.map