-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Right now custom PartitionedRateLimiter<HttpContext>
is supported only as GlobalLimiter
and it is not possible to attach custom implementation of PartitionedRateLimiter<HttpContext>
to name with AddPolicy
.
The closest thing that AddPolicy
accepts is callback that needs to return RateLimitPartition<TPartitionKey>
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<HttpContext, PartitionedRateLimiter<HttpContext>> factory)
or
public RateLimiterOptions AddPolicy(string policyName, PartitionedRateLimiter<HttpContext> rateLimiter)
Additional context
No response