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

Make RpcClient (Auto)Closeable #1032

Closed
JHahnHRO opened this issue May 15, 2023 · 1 comment
Closed

Make RpcClient (Auto)Closeable #1032

JHahnHRO opened this issue May 15, 2023 · 1 comment
Milestone

Comments

@JHahnHRO
Copy link
Contributor

Is your feature request related to a problem? Please describe.

RpcClient is a good fit for one-off RPCs. However for a one-off use one has to remember to close the RpcClient otherwise, the channel will retain the consumer forever and when the channel is used some time later for another one-off RPC, the new and old consumer will collide.

It sure would be nice to have some support with not-forgetting this. I for one certainly need it.

Describe the solution you'd like

The preferred way to remind developers to call the close method surely would be to make RpcClient implement Closeable or at least AutoCloseable if we truly do not want the close method to be idempotent (I cannot imagine why we would want that, but maybe there's a reason it's written as non-idempotent now).

Describe alternatives you've considered

Implementing the try-with-resources-construct I want to use by writing the appropriate try-finally-block myself. This is a. ugly and b. error-prone, because it's one of the cases where one needs an extra layer of try-catch inside the finally-block. Of course I can look up what the correct pattern is, but we force that onto users?

Additional context

No response

@acogoluegnes
Copy link
Contributor

Closed in #1033.

@acogoluegnes acogoluegnes added this to the 5.18.0 milestone May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants