Skip to content

Commit 7154992

Browse files
gustavoavenameta-codesync[bot]
authored andcommitted
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: c7f2186897ae9036241ebc44a37141d31c61c569
1 parent 90fa069 commit 7154992

File tree

1 file changed

+2
-1
lines changed
  • eden/mononoke/repo_attributes/commit_rate_limit/src

1 file changed

+2
-1
lines changed

eden/mononoke/repo_attributes/commit_rate_limit/src/cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ pub struct ChangesetEligibilityCache {
2727
impl std::fmt::Debug for ChangesetEligibilityCache {
2828
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2929
f.debug_struct("ChangesetEligibilityCache")
30-
.finish_non_exhaustive()
30+
.field("entry_count", &self.entries.entry_count())
31+
.finish()
3132
}
3233
}
3334

0 commit comments

Comments
 (0)