-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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]: System.Threading.RateLimiting RateLimitLease should implement IAsyncDisposable #77669
Comments
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. |
Tagging subscribers to this area: @mangod9 Issue DetailsBackground and motivationHi, I'm working on a Redis extension library on top of When the My suggestion would be to make API Proposalnamespace System.Threading.RateLimiting
{
public abstract class RateLimitLease : IDisposable, IAsyncDisposable
{
...
protected virtual ValueTask DisposeAsync(bool disposing)
{
return default;
}
public ValueTask DisposeAsync()
{
return DisposeAsync(true);
}
}
} API Usageprivate sealed class RedisConcurrencyLease : RateLimitLease
{
...
protected override ValueTask DisposeAsync(bool disposing)
{
if (_disposed)
{
return;
}
_disposed = true;
if (_id != null)
{
return _limiter?.ReleaseAsync(_id);
}
return default;
}
} Alternative DesignsNo response RisksNo response
|
Tagging @BrennanConroy @davidfowl @halter73 @JamesNK for visibility |
Background and motivation
Hi, I'm working on a Redis extension library on top of
Microsoft.AspNetCore.RateLimiting
(for multi-node deployments), using the new Rate Limiting support added in NET 7: https://github.com/cristipufu/aspnetcore-redis-rate-limitingWhen the
ConcurrencyLimiter
'sConcurrencyLease
gets disposed, we need to basically decrement the count for that particular policy. At the moment, the current API forces me to use the sync version.My suggestion would be to make
RateLimitLease
implementIAsyncDisposable
, such that we can call async APIs when the lease is released: https://github.com/cristipufu/aspnetcore-redis-rate-limiting/blob/master/src/RedisRateLimiting/Concurrency/RedisConcurrencyRateLimiter.cs#L114API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: