Commit 7154992
commit_rate_limit: migrate hook to use facet and check_all_commit_rate_limits
Summary:
## This stack
Promote commit rate limiting from a hook-only feature (JSON config) to a
first-class Mononoke feature with thrift-defined config, repo facet,
mononoke_api primitive, SCS endpoint, scsc CLI, and consolidated hook.
## This diff
Makes `CommitRateLimitHook` backwards-compatible with both legacy and
facet-based config:
- **Legacy path**: If the hook's `config_json` contains rate limit rules
(non-empty `limits`), the hook uses them directly via
`check_commit_rate_limit()` — a single-rule check with the inline config.
This keeps existing hook instances working unchanged.
- **Facet path**: If no inline rules are configured, the hook reads from
the `CommitRateLimit` repo facet and calls
`check_all_commit_rate_limits()` to evaluate all rules concurrently.
This dual-path design allows deploying a new facet-based hook instance
alongside existing legacy hook instances during migration, without
requiring an atomic config switchover.
On the facet path, all exceeded rules are reported in the rejection
message (no early return on first failure).
Reviewed By: YousefSalama
Differential Revision: D99265455
fbshipit-source-id: c7f2186897ae9036241ebc44a37141d31c61c5691 parent 90fa069 commit 7154992
1 file changed
+2
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
0 commit comments