mattrguerra/meridian-ops-boardmainPrivate on GitHub, published here in full

constants.ts

Language TypeScript1.3 KB28 lines

packages/plinth-client/src/constants.ts

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