Skip to content
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

[API Proposal]: Make RateLimitPartition.Factory public #70597

Closed
wtgodbe opened this issue Jun 10, 2022 · 2 comments
Closed

[API Proposal]: Make RateLimitPartition.Factory public #70597

wtgodbe opened this issue Jun 10, 2022 · 2 comments
Labels
api-approved API was approved in API review, it can be implemented area-System.Threading blocking Marks issues that we want to fast track in order to unblock other important work

Comments

@wtgodbe
Copy link
Member

wtgodbe commented Jun 10, 2022

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?

@wtgodbe wtgodbe added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jun 10, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 10, 2022
@wtgodbe wtgodbe added blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Jun 10, 2022
@ghost
Copy link

ghost commented Jun 16, 2022

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Issue Details

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?

Author: wtgodbe
Assignees: -
Labels:

area-System.Threading, blocking, untriaged, api-ready-for-review

Milestone: -

@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation untriaged New issue has not been triaged by the area owner labels Jun 22, 2022
@wtgodbe wtgodbe closed this as completed Jun 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Threading blocking Marks issues that we want to fast track in order to unblock other important work
Projects
None yet
Development

No branches or pull requests

3 participants