4 ms·
I'm glad you asked, because I should clarify that my use case is "fire and forget" tasks. The controller is not interested in the result of the service's operat
by FroshKiller 3y ago
I'm glad you asked, because I should clarify that my use case is "fire and forget" tasks. The controller is not interested in the result of the service's operation, so there is no need for any return value.
Regarding your other points:
Dependencies can be traced by the job type associated with the channel. It is somewhat indirect but no more indirect than an interface, really.
Since I am not concerned with results, mocking is even easier. I just have a service implementation that consumes from a ChannelReader and discards the result. This is really a single class since it can take a type parameter if that makes sense--no need for separate mocks.
I haven't used Scrutor, so I can't speak to that.
Reading and writing from a channel are also just method calls. There are synchronous and asynchronous options for both.
I don't have any open code to share, but I found the design very intuitive. If you read the documentation and follow your intuition, you will probably implement things exactly as I did.
Also I am not trying to convince anyone that channels are the best answer! I just found them helpful in my projects and think they have not been promoted very well in the .NET sphere.