-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add CreateChained to RateLimiter #107230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CreateChained to RateLimiter #107230
Conversation
Note regarding the
|
Note regarding the
|
...raries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/ChainedRateLimiter.cs
Outdated
Show resolved
Hide resolved
0d7105f
to
7ac35ca
Compare
7ac35ca
to
6e4bd1a
Compare
6e4bd1a
to
fa7a5af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces chained rate limiter support by adding a new CreateChained API and corresponding implementations that acquire and aggregate leases from multiple rate limiters. Key changes include:
- Adding a CombinedRateLimitLease class that aggregates metadata and disposes inner leases in reverse order.
- Creating a ChainedRateLimiter to coordinate acquisition from a sequence of limiters using common acquisition logic.
- Exposing a new static CreateChained method on RateLimiter and updating related tests and partitioned limiter implementations.
Reviewed Changes
File | Description |
---|---|
src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/CombinedRateLimitLease.cs | New combined lease implementation aggregating multiple leases and their metadata. |
src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/ChainedRateLimiter.cs | New chained rate limiter with shared acquisition logic for synchronous and asynchronous operations. |
src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/RateLimiter.cs | Added static CreateChained method with necessary validations. |
src/libraries/System.Threading.RateLimiting/tests/Infrastructure/Utils.cs | Added ThrowDisposeLease for testing failure scenarios in Dispose. |
src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/ChainedPartitionedRateLimiter.cs | Updated to clone the limiters array and reference ChainedRateLimiter.CommonAcquireLogic for consistency. |
src/libraries/System.Threading.RateLimiting/ref/System.Threading.RateLimiting.cs | Updated public API reference to include CreateChained. |
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
...raries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/ChainedRateLimiter.cs
Outdated
Show resolved
Hide resolved
...raries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/ChainedRateLimiter.cs
Outdated
Show resolved
Hide resolved
...raries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/ChainedRateLimiter.cs
Outdated
Show resolved
Hide resolved
Thanks! Sorry it took so long |
Closes #98017
cc @BrennanConroy @TonyValenti