mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
Route every SDK request through one GovernedRestClient (installed via Sdk::new_without_suspension, replacing the SDK's header-only suspension layer). It enforces: - Bounded concurrency: at most MAX_IN_FLIGHT (4) requests in flight, so attachment sub-loops, on-demand IMAP fetches across connections, and the syncer can no longer stampede the API in parallel. - Throttle backoff: on HTTP 429/503 it suspends all outbound traffic, honoring the server's retry-after / suspension-time header, or an escalating default backoff (2s to 60s) when the server gives no hint (the gap the SDK left, which let the bridge keep hammering). Because a 429 still returns to the caller while the gate is armed, the existing retry layers become self-correcting: their next attempt blocks on the gate instead of amplifying the flood. 7 unit tests: concurrency cap, throttle classification, backoff honor/clamp/escalate/reset, suspension gate timing.