-
Notifications
You must be signed in to change notification settings - Fork 592
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
Reduce close / abort methods in public API #1008
Reduce close / abort methods in public API #1008
Conversation
Hmm it works with SDK V 5.0, but build still uses 3.1.x which somehow doesn't like the => not needed anymore, see comment from @danielmarbach |
There are some known users that mock the connection API interface. I doubt it's a widely used approach but some prominent projects could have adopted it. |
Are there any downsides besides all contributors having to upgrade? I'd say requiring .NET Core 5 for our own development is fine. |
I'm all for making the Public API simpler, though a quick look at the PR, I'm not quite sure how this PR does that. It seems to just be shuffling the APIs around, not actually reducing anything.
It should be perfectly fine to move to a newer SDK because that has no impact on the consumers of the client. However, something seems off here. I can't think of a reason why the SDK version would impact whether or not the code compiles. |
It reduces the part that is mandatory for implementing. We can consider removing the |
The reduction happens at the IConnection and IModel interface. For convenience and to reduce the update effort the existing api are now extension methods. => interface smaller, easier to implement it while keeping the public facing api usage the same. Our benefits are the reduced number of implementation in e.g Connection & AutorecoveringConnection while for the customer nothing changes (except he may calls close now through an extension method)
It is indeed strange, but I have had it happened to me once or twice that they fixed some bug in a newer SDK. This feels just like it. You can look at the code in question. It's a instance method of e.g. Connection, that calls this.Abort. (This implementing an IConnection and Abort being an extension method on IConnection) So this should be fine, but somehow the old SDK doesn't like it. 🤷♂ |
Happy to update it if it's wanted. With this change it's now just deleting the extension method 😊 |
Thank you! |
return Close(new ShutdownEventArgs(ShutdownInitiator.Application, | ||
replyCode, replyText), | ||
abort); | ||
_ = CloseAsync(new ShutdownEventArgs(ShutdownInitiator.Application, replyCode, replyText), abort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to drop the task here because it means we are no longer materializing any exceptions or waiting for the operation to complete
was this only ever called by the upper layers that are now in the extension methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. But I agree that this should probably be fixed in another PR. (I didn't want to mix cleanup and fixing in a pr)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the visibility is why I renamed it to CloseAsync and explicitely dropped the task with _ =. Glad it already worked out😛
Proposed Changes
There are 3 close / abort functions in the public API. This forces a lot of similar implementations in AutorecoveryConnection.
This PR removes all of them except one in the public API and replaces it with extension methods with the same parameters. (This means a recompile should be enough for customers, if they haven't mocked the interface itself)
Types of Changes
Checklist
CONTRIBUTING.md
document