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

Add TranslateKey to PartitionedRateLimiter #69407

Merged
merged 2 commits into from Jul 21, 2022

Conversation

BrennanConroy
Copy link
Member

Part of #65400

Main question is around lifetime. Should dispose dispose the inner limiter? Should it be an option?

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented May 16, 2022

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

Issue Details

Part of #65400

Main question is around lifetime. Should dispose dispose the inner limiter? Should it be an option?

Author: BrennanConroy
Assignees: BrennanConroy
Labels:

area-System.Threading

Milestone: 7.0.0

@trylek
Copy link
Member

trylek commented Jun 20, 2022

I'm not an expert in this area. @kouvel, could you please review this change or suggest someone who can?

@BrennanConroy
Copy link
Member Author

@halter73 will be reviewing this

@trylek
Copy link
Member

trylek commented Jun 20, 2022

Thanks Brennan for clarifying. I'm just asking as this change continues popping up on our stale PR radar so we need to evaluate what PR's are still being worked on vs. which ones have been abandoned.

@BrennanConroy BrennanConroy requested review from halter73 and removed request for halter73 July 12, 2022 20:50
// REVIEW: Do we want to have an option to dispose the inner limiter?
// Should the default be to dispose the inner limiter and have an option to not dispose it?
// See Stream wrappers like SslStream for prior-art
return new TranslatingLimiter<TResource, TOuter>(this, keyAdapter);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. StreamWriter does the same thing with leaveOpen, so there's definitely precedent here. I think this is the more convenient behavior considering how this API is likely to be used. Keeping around the original PartitionedRateLimiter just to track it for disposal is annoying. Do we like just adding a bool parameter?

public PartitionedRateLimiter<TOuter> TranslateKey<TOuter>(Func<TOuter, TResource> keyAdapter, bool leaveOpen = false);

We could add an options type if we think we're going to make this even more configurable in the future, but I think that's probably excessive.

For now, without a leaveOpen option, I think we have to default to not taking ownership like you have since that's more flexible although it's less convenient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we like just adding a bool parameter?

I think so. I am unable to think of any other potential future options at this time. The prior-art with Stream wrappers and StreamWriter will be helpful when advocating for an API change.

Edit: #72551

@BrennanConroy
Copy link
Member Author

Test failure is a known issue, unrelated to this change.

@BrennanConroy BrennanConroy merged commit d6fef3b into dotnet:main Jul 21, 2022
@BrennanConroy BrennanConroy deleted the brecon/translate branch July 21, 2022 15:53
@dotnet dotnet locked as resolved and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants