constants.ts
Language TypeScript1.3 KB28 lines
/** Single endpoint; the method is a query parameter. */export const PLINTH_BASE_URL = 'https://orders.meridiandisplay.example/api/v2/dispatch'/*** Plinth allows 10 requests per 10 seconds. We throttle to 9 per 10 seconds.** The one-request headroom absorbs clock skew between our token bucket and* theirs: the windows do not start at the same instant, so a burst that is* exactly at the limit by our clock can be one over by theirs. It also means a* retry after a transient failure does not push the next window over and* cascade.** It costs nothing at this volume: a full active-order sweep is well under a* dozen calls, roughly ten seconds inside a 15-minute cron. The limit only* bites if something fans out per-order detail calls across hundreds of* orders, which is exactly the shape to avoid.** Bitrix's 7 per 8 seconds looks close but comes from a different fact (a* conservative choice under a 2/s sustained limit). Keep the two separate: a* shared value raised from Bitrix's docs would silently raise Plinth's too,* where it starts returning rate-limit errors.*/export const PLINTH_RATE_LIMIT = {capacity: 9,refillPerSecond: 9 / 10,documentedLimit: { requests: 10, perSeconds: 10 },source: 'Plinth API reference',} as const