Files
gods-eye-view/server/providers/rainViewerGovernor.js
T
Bilawal SidhuandSandiv Dathunarachchi d496dd9f33 feat(weather): global rain radar from RainViewer
Add a Global (RainViewer) option to Rain radar beside the US MRMS
radar. The proxy pins RainViewer's tile host, validates frames and
Web Mercator tile coordinates, and limits upstream tile requests to
80 a minute. Globe basemaps draw the tiles; on 3D Tiles the shell
composes them into one equirectangular image per frame and detail
window.

Co-authored-by: Sandiv Dathunarachchi <[email protected]>
2026-09-28 20:46:58 -05:00

13 lines
475 B
JavaScript

/** Admit at most 80 requests in a rolling minute; return retry seconds or zero.
* Call only at the upstream boundary, after cache lookup and coalescing. */
export function createRainViewerGovernor() {
const attempts = [];
return (now) => {
while (attempts.length && now - attempts[0] >= 60_000) attempts.shift();
if (attempts.length >= 80)
return Math.max(1, Math.ceil((60_000 - (now - attempts[0])) / 1000));
attempts.push(now);
return 0;
};
}