You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#61788 added the Rate Limiting work from #52079 and while working on it we realized it made sense for rate limiters to be disposable. It started with the TokenBucket implementation which has a timer instance which should be disposed of. But it also made sense for the other rate limiters to release any pending acquisition requests from limiter.WaitAsync(..., token); as well as clean up any cancellation token registrations.
Additionally, we expect some 3rd party implementations to be backed by a network resource and async disposal is preferred in those cases.
As well as implementing the two virtual methods on the rate limiter implementations (Concurrency, TokenBucket, FixedWindow, SlidingWindow)
We went ahead and made the API disposable, filing this to make sure we properly API review it.
API Proposal
public abstract class RateLimiter
+ : IAsyncDisposable, IDisposable
{
+ protected virtual void Dispose(bool disposing) { }+ public void Dispose() { }+ protected virtual ValueTask DisposeAsyncCore() { }+ public async ValueTask DisposeAsync() { }
}
Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.
Issue Details
Background and motivation
#61788 added the Rate Limiting work from #52079 and while working on it we realized it made sense for rate limiters to be disposable. It started with the TokenBucket implementation which has a timer instance which should be disposed of. But it also made sense for the other rate limiters to release any pending acquisition requests from limiter.WaitAsync(..., token); as well as clean up any cancellation token registrations.
Additionally, we expect some 3rd party implementations to be backed by a network resource and async disposal is preferred in those cases.
As well as implementing the two virtual methods on the rate limiter implementations (Concurrency, TokenBucket, FixedWindow, SlidingWindow)
We went ahead and made the API disposable, filing this to make sure we properly API review it.
API Proposal
public abstract class RateLimiter
+ : IAsyncDisposable, IDisposable
{
+ protected virtual void Dispose(bool disposing) { }+ public void Dispose() { }+ protected virtual ValueTask DisposeAsyncCore() { }+ public async ValueTask DisposeAsync() { }
}
Background and motivation
#61788 added the Rate Limiting work from #52079 and while working on it we realized it made sense for rate limiters to be disposable. It started with the TokenBucket implementation which has a timer instance which should be disposed of. But it also made sense for the other rate limiters to release any pending acquisition requests from
limiter.WaitAsync(..., token);
as well as clean up any cancellation token registrations.Additionally, we expect some 3rd party implementations to be backed by a network resource and async disposal is preferred in those cases.
As well as implementing the two virtual methods on the rate limiter implementations (Concurrency, TokenBucket, FixedWindow, SlidingWindow)
We went ahead and made the API disposable, filing this to make sure we properly API review it.
API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: