/** * Saved-location lightning pre-warm: subscribe saved locations at startup and keep them * subscribed for as long as they stay saved. * * The Blitzortung feed only buffers strikes for an area while it is subscribed, and the * service prunes any subscription idle for longer than `SUBSCRIPTION_IDLE_THRESHOLD_MS`. * A single startup pre-warm therefore lapsed after about an hour. This module re-warms * every saved location on an interval derived from that threshold, so a saved location's * access stamp never ages past it. A location removed from the store is simply not * re-warmed, and the ordinary prune drops it. * * - The timer starts whenever the gate passes, even with an empty or unreadable store, so * a location saved (or a file repaired) later is picked up on the next tick. An empty * store opens no connection: nothing connects until the first `prewarmLocation` call. * - The store read is guarded, and only the read: an unreadable file must not stop the * server booting, and a fault anywhere else must not be hidden behind the same catch. * On an unreadable tick nothing is re-warmed, so subscriptions age out rather than being * extended from data that could not be read. * - Pre-warm never evicts. The service skips a saved location that does not fit instead of * displacing another subscription; this module reports the skipped count when it changes. */ import { type PrewarmOutcome } from '../services/blitzortung.js'; export interface PrewarmScheduler { setInterval(fn: () => void, ms: number): ReturnType; clearInterval(handle: ReturnType): void; } export interface LightningPrewarmDeps { /** `toolConfig.isEnabled('get_lightning_activity')`. */ toolEnabled: boolean; /** The raw `WEATHER_LIGHTNING_PREWARM` value; `'false'` opts out. */ optOutValue: string | undefined; /** Synchronous store read. May throw when the file is unreadable. */ readSavedLocations: () => Array<{ latitude: number; longitude: number; }>; prewarmLocation: (latitude: number, longitude: number, radiusKm?: number, outcome?: PrewarmOutcome) => Promise; scheduler?: PrewarmScheduler; intervalMs?: number; } export interface LightningPrewarmHandle { stop(): void; } export declare function startLightningPrewarm(deps: LightningPrewarmDeps): LightningPrewarmHandle; //# sourceMappingURL=lightningPrewarm.d.ts.map