Add --max-rps throttle for exchange-graph and exchange-ews #76

Merged
jcoffey-dev merged 1 commits from feat/migrate-max-rps into main 2026-11-13 01:20:37 +00:00
Owner

Surfaces a proactive throttle knob for the rate-limited Microsoft 365 importers. import exchange-graph and import exchange-ews take --max-rps <RPS> to cap how many requests start per second across all worker connections.

Why: the clients already honor a 429/503 reactively (its Retry-After, then a shared backoff across workers), but nothing let an operator stay under a known tenant limit in the first place. --max-rps does that. Off by default (uncapped); composes with the connection count — requests in flight are not limited, only how often a new one begins.

Design: a reusable Pacer lives next to Cooldown in jmap::retry. Interval is set once after the client is built (like the logger, via set_max_rps), so new() signatures and their callers are untouched; a zero interval is free on the hot path; an idle gap banks no burst credit. Both M365 clients call pace.wait() at the top of their request loop, beside the existing cooldown().wait(). A validating parser rejects non-positive/non-finite rates.

Scope: surfaced on the two HTTP-request importers, where requests-per-second is the natural lever. For Gmail/Google the lever stays --imap-connections (concurrency), already surfaced — RPS does not map onto stateful IMAP.

7 new tests (Pacer: disabled-by-default, spacing, immediate-when-off, no-burst; CLI: default-off/parsed + positive-only, for both importers). README/docs/usage.md EWS+Graph sections + CHANGELOG. fmt/clippy/cargo test --locked (1214 lib + integration) green; smoke-tested flag validation + acceptance in the real binary.

Rolling-bucket item: throttle/concurrency knobs surfaced for M365/Google.

Surfaces a **proactive throttle knob** for the rate-limited Microsoft 365 importers. `import exchange-graph` and `import exchange-ews` take `--max-rps <RPS>` to cap how many requests start per second across all worker connections. **Why:** the clients already honor a 429/503 reactively (its `Retry-After`, then a shared backoff across workers), but nothing let an operator stay *under* a known tenant limit in the first place. `--max-rps` does that. Off by default (uncapped); composes with the connection count — requests in flight are not limited, only how often a new one begins. **Design:** a reusable `Pacer` lives next to `Cooldown` in `jmap::retry`. Interval is set once after the client is built (like the logger, via `set_max_rps`), so `new()` signatures and their callers are untouched; a zero interval is free on the hot path; an idle gap banks no burst credit. Both M365 clients call `pace.wait()` at the top of their request loop, beside the existing `cooldown().wait()`. A validating parser rejects non-positive/non-finite rates. **Scope:** surfaced on the two HTTP-request importers, where requests-per-second is the natural lever. For Gmail/Google the lever stays `--imap-connections` (concurrency), already surfaced — RPS does not map onto stateful IMAP. 7 new tests (Pacer: disabled-by-default, spacing, immediate-when-off, no-burst; CLI: default-off/parsed + positive-only, for both importers). README/docs/usage.md EWS+Graph sections + CHANGELOG. fmt/clippy/`cargo test --locked` (1214 lib + integration) green; smoke-tested flag validation + acceptance in the real binary. Rolling-bucket item: throttle/concurrency knobs surfaced for M365/Google.
jcoffey-dev added 1 commit 2026-11-12 23:37:46 +00:00
Add --max-rps throttle for exchange-graph and exchange-ews
ci / test (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 3m11s
ci / announce (pull_request) Skipped
763fdca425
Microsoft 365 throttles per app and per mailbox. The clients already
honor a 429/503 reactively (its Retry-After, then a shared backoff
across the workers), but nothing let an operator stay under a known
limit in the first place.

--max-rps caps how many requests may start per second across all worker
connections, a proactive throttle. It is off by default (uncapped) and
composes with the connection count: requests in flight are not limited,
only how often a new one begins.

A reusable Pacer lives next to Cooldown in jmap::retry: the interval is
set once after the client is built (like the logger), a zero interval is
free on the hot path, and an idle gap banks no burst credit. Both M365
clients call it at the top of their request loop. Surfaced on the two
HTTP-request importers, where requests-per-second is the natural knob;
for Gmail the lever stays --imap-connections.
jcoffey-dev merged commit da814e4e23 into main 2026-11-13 01:20:37 +00:00
jcoffey-dev deleted branch feat/migrate-max-rps 2026-11-13 01:20:37 +00:00
Sign in to join this conversation.