Version 7 API - issue with mixing sync / async in same API #1471
Replies: 10 comments 23 replies
-
cc @kjnilsson |
Beta Was this translation helpful? Give feedback.
-
I agree that this makes sense. We did the same thing in NServiceBus years ago. |
Beta Was this translation helpful? Give feedback.
-
Hi, I think the way forward when doing network operations is going full async. Other libraries have gone full async like renci.ssh If someone needs sync operations the calls can be wrapped, carefully to avoid deadlocks, by using for example a custom synchornization context like this one: https://github.com/restsharp/RestSharp/blob/dev/src/RestSharp/AsyncHelpers.cs |
Beta Was this translation helpful? Give feedback.
-
Async only makes sense to me (since this will be a new major). |
Beta Was this translation helpful? Give feedback.
-
Async only makes perfect sense to me. |
Beta Was this translation helpful? Give feedback.
-
Sync only 🤣 Of course I'm trolling. The maintenance effort for a small team like yours to provide sync and async plus all the bugs that come with that decision due to the requirement of duplicating larger portion of of the code base is not worth it and would unnecessarily stall efforts in other areas for the sake of pleasing a very small and diminishing (shall we say diminished?) user base |
Beta Was this translation helpful? Give feedback.
-
I really appreciate the fast and unanimous feedback. I'll begin deleting code soon 😸 |
Beta Was this translation helpful? Give feedback.
-
Async all the way for the win!!! Are you able to collect a memory dump of the hang process to determine where the hang is? |
Beta Was this translation helpful? Give feedback.
-
One scenario I wanted to call out is putting the In .NET Aspire we are using Would it be possible to keep this synchronous method to support putting RabbitMQ connections in DI? |
Beta Was this translation helpful? Give feedback.
-
@eerhardt I would like to add I'm not against keeping a synchronous connection method. The intent of my comment here is to expand on what you wrote and provide another perspective. Hopefully my comment is well received. As you have pointed out the .NET ecosystem had already with the introduction of the hosting and the dependency injection abstraction a general problem of lacking a good extension point to initialize connection means. Like you mentioned there is no way on the DI abstractions with the built in mechanics to asynchronously initialize a component when it is resolved or when you try to use the hosted services to do that you run into ordering problems due to the hosted services constructor dependencies being resolved for all the hosted services at once and then the hosted services being started sequentially or with the newest additions even concurrently. Many libraries out there that moved to an asynchronous only model suffer from the lack of this capability and there are various workarounds required to initialize components asynchronously. So I wonder why it should be up to an individual library to keep certain APIs around, and having to deal with that complexity there as well as having to explain why there is a single sync IO-bound method still around instead of leaving it up the host entry point to deal with this problem? (I'm aware that there are a magnitude of more hosts around that then have to deal with it but again this seems to be a larger ecosystem problem anyway). When I look at Aspire components it seems even there we can see this problem sometimes being addressed and sometimes not. For example when I look at the RabbitMQ component it establishes a connection as part of the component declaration while for example the SQL Client, MySQL component doesn't seem to try to open the connect before it is being resolved. This seems to indicate that are components that either rely on implicit initialization mechanisms of the component exposed, manually manage connection mechanisms as part of the Aspire wire-up or rely on the client of the exposed component to initialize the connections. Given that Aspire is in control of the host and all the registrations couldn't Aspire too leverage abstractions like hosted services, lifecycle hooks of Aspire etc. to make sure the connection is established asynchronously too? Yes there is still the problem of ordering of the wire up vs the usage of the components order but that seems to be also generally a problem that the entire .NET ecosystem has today with the hosting and DI abstractions we have in place. |
Beta Was this translation helpful? Give feedback.
-
cc @michaelklishin @stebet @paulomorgado @bollhals @danielmarbach @bording @pabermod @plewam @Zerpet @Gsantomaggio @eerhardt @davidfowl
Hi everyone,
I am cc-ing everyone who has recently made a major contribution or has given input on issues or pull requests.
I have been making slow and steady progress on version 7 of this client. Currently, I'm making sure that
Async
methods take a cancellation token, and use it correctly (the latter part is the difficult part, of course).Throughout the course of getting version 7 ready, I have run into issues where tests that exercise the sync-over-async API fail to run, usually on the
net472
target. See this workflow run, which was cancelled at the 6 hour time limit:https://github.com/rabbitmq/rabbitmq-dotnet-client/actions/runs/7508636025/job/20444501415
I have pretty much reached the end of my patience for having a sync and async API in the same set of interfaces and assemblies. Team RabbitMQ is small, and in addition to working on this library (and others) I do a lot of support for commercial RabbitMQ customers. I would like to get version 7 of this library shipped in a reasonable amount of time so I am going to propose that we do one of the following for version 7:
async
only. If a synchronous API is needed, users can stay on version 6. We will establish an end-of-life date for version 6 when version 7 ships. This is my preferred solution.async
API and non-async
API. This can be done at the namespace level, assembly level, whatever.Make your opinions known here!
Beta Was this translation helpful? Give feedback.
All reactions