-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.ThreadingblockingMarks issues that we want to fast track in order to unblock other important workMarks issues that we want to fast track in order to unblock other important work
Description
Background and motivation
This will allow aspnetcore's RateLimitingMiddleware to resolve a Limiter from a given TKey without having to use reflection. The use case is that users provide a Func<HttpContext, RateLimitPartition<TKey>>, which we want to convert to a Func<HttpContext, RateLimitPartition<AspNetKey<TKey>>> (using Factory) - AspNetKey being used to remove possible ambiguities between TKeys.
API Proposal
namespace System.Threading.RateLimiting
{
public struct RateLimitPartition<TKey>
{
public RateLimitPartition(TKey partitionKey, Func<TKey, RateLimiter> factory)
public TKey PartitionKey { get; }
+ public Func<TKey, RateLimiter> Factory {get; }
}API Usage
RateLimiter limiter = partition.Factory("MyLimiter");Alternative Designs
The other option is to use private reflection
Risks
N/A?
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.ThreadingblockingMarks issues that we want to fast track in order to unblock other important workMarks issues that we want to fast track in order to unblock other important work