Skip to content

ref(allocation-policies): Template method for the concurrency policies - #8641

Closed
dezzeddi wants to merge 1 commit into
masterfrom
dani/concurrent-policies-template-method
Closed

dezzeddi wants to merge 1 commit into
masterfrom
dani/concurrent-policies-template-method

Conversation

@dezzeddi

Copy link
Copy Markdown
Member

ConcurrentRateLimitAllocationPolicy (CRL), ReferrerGuardRailPolicy (RGR) and CrossOrgQueryAllocationPolicy (XO) each re-implement the same flow: skip some queries, count the query in a Redis bucket, compare with a limit, end the query afterwards.

BaseConcurrentRateLimitAllocationPolicy now runs that flow (_get_quota_allowance, _update_quota_balance). Subclasses supply hooks:

  • _rate_limit_params: bucket and limit
  • _pass_through_allowance / _skips_balance_update: queries they don't count
  • _allowance: how the decision becomes a QuotaAllowance (RGR's throttling stays here)

Zero behaviour change: buckets, limits, explanations, metrics and decisions are the same. Two details kept on purpose:

  • CRL still ends pass-through-referrer queries and only skips cross-org ones on update, as before.
  • RGR and XO end queries with their real limit instead of a placeholder 22. The limit isn't used when ending a query.

Conflicts with #8634, #8635, #8636 and #8637 (same files); whichever merges second needs a rebase.

ConcurrentRateLimitAllocationPolicy, ReferrerGuardRailPolicy and
CrossOrgQueryAllocationPolicy each re-implemented the same count-check-end
flow. BaseConcurrentRateLimitAllocationPolicy now runs it; subclasses supply
the bucket and limit, which queries they skip, and how a decision becomes an
allowance. Buckets, limits, explanations and decisions are unchanged.
@dezzeddi

Copy link
Copy Markdown
Member Author

Combined into #8643.

@dezzeddi dezzeddi closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant