Support custom `PartitionedRateLimiter<HttpContext>` per endpoint
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
Right now custom `PartitionedRateLimiter` is supported only as `GlobalLimiter` and it is not possible to attach custom implementation of `PartitionedRateLimiter` to name with `AddPolicy`.
The closest thing that `AddPolicy` accepts is callback that needs to return `RateLimitPartition` which has `Factory` property that returns `RateLimiter` and that rate limiter is not `HttpContext` aware.
Background:
We need to build an internal endpoint that needs to do some concurrency rate limiting based on some HTTP header. It should make priorities based on value from header, not just plain FIFO or LIFO queue like `ConcurrencyLimiter` does. In order to prioritise acquires, rate limiter needs to know for `HttpContext`, calculate priority when some `Lease` is disposed and pick the next from queue to be acquired.
### Describe the solution you'd like
On `RateLimiterOptions`:
`public RateLimiterOptions AddPolicy(string policyName, Func> factory)`
or
`public RateLimiterOptions AddPolicy(string policyName, PartitionedRateLimiter rateLimiter)`
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.