-
Notifications
You must be signed in to change notification settings - Fork 145
#103 - Add support for ICommand IRequest without Unit #228
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for the PR! Will have a look this weekend |
|
Hmm I did not realize we would end up having completely different pipelines (I would not have asked the pipeline ordering question if I had realized that). This feels like pretty bad UX if we consider that users who implement pipeline behaviors and have responseless messages would have to essentially duplicate their behaviors.. Aren't we essentially trading We would close the gap on the drift from the MediatR contract with this but open up this kind of unexpected behavior difference in terms of pipeline behaviors. I'm starting to think the only viable options here are to do the same thing as MediatR does or not do it at all. Thoughts? |
|
True, keeping in mind closing the gap with MediatR i agree in having a new unexpected behavior with the pipelines. I will adjust this to reuse the same pipelines. |
|
@martinothamar updated the PR. Created a Void wrapper that returns the default unit. Let me know if this implementation works for you! |
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.
Thanks for working on this! Looking promising, left some comments. If you feel stronly opposed to any of them feel free to say so 😄 Additional comments:
- We should add responseless requests/commands to
common/Messages.cs, that will let us catch som additional bugs as we know have more logic/branching related to this - I think it makes sense to introduce some benchmarking to compare the performance of sending requests with and without responses, since we now likely will incurr some overhead for messages without responses due to having to manage the transitions between having
Unitand not. These benchmarks don't have to compare against other libraries, I think just having 2 methods comparing with and withour response is good enough
src/Mediator.SourceGenerator/Implementation/Analysis/CompilationAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Mediator.SourceGenerator/Implementation/Models/RequestMessageHandlerWrapperModel.cs
Outdated
Show resolved
Hide resolved
src/Mediator.SourceGenerator/Implementation/Models/RequestMessageModel.cs
Outdated
Show resolved
Hide resolved
src/Mediator.SourceGenerator/Implementation/Models/RequestMessageModel.cs
Outdated
Show resolved
Hide resolved
src/Mediator.SourceGenerator/Implementation/resources/Mediator.sbn-cs
Outdated
Show resolved
Hide resolved
....Tests/_snapshots/BasicTests.Multiple_Notification_Handlers_One_Class#Mediator.g.verified.cs
Show resolved
Hide resolved
|
|
||
| var original = pipelineSteps.Select(p => p.LastMsgTimestamp).ToArray(); | ||
| var ordered = pipelineSteps.Select(p => p.LastMsgTimestamp).OrderBy(x => x).ToArray(); | ||
| Assert.True(original.SequenceEqual(ordered)); |
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.
Isn't there only 1 pipelinebehavior here? I think we need to add more for this test to add value
src/Mediator.SourceGenerator/Implementation/resources/Mediator.sbn-cs
Outdated
Show resolved
Hide resolved
|
Thanks for the feedback and comments. |
|
@martinothamar I finished the rework.
If this all works out I will check the remaining issues |
|
@mvput would be great to have this available, but looks like there is a conflict blocking from eventual merge? 👀 @martinothamar |
Yes, currently awaiting the feedback from @martinothamar. If all works out I can finish the work for this PR. |
|
Hey, sorry, been busy trying to wrap up work for 3.1.. This PR will go into v4 (breaking changes). We need to give 3.1 some time to stabilize at it is currently in preview. Doing a quick pass through this now |
|
|
||
| namespace Mediator; | ||
|
|
||
| public class ValueTaskWrapper<T> : IValueTaskSource<T> |
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.
Does this actually save an allocation? If we need to construct this for the async path anyway. I think it would be useful to have some benchmarks results here comparing the performance of
- sync handler, before and after this PR
- async handler, before and after this PR
For requests with unit/without response
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.
Once we have validated the design, if we end up sticking with this, it should just stay in the generated code as an internal type (internals namespace). I don't want this to be part of the public contract
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.
Will run some performance benchmarks later this weekend!
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.
Performed the benchmarks on 3.0 and 4.0-preview (this PR). The results are attached in the comment.
Both runs are done in the same conditions on the workstation. Will do some analysis on the results
benchmark_v4.0-preview.txt
benchmark_v3.0.txt
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.
Based on the performance benchmarks I did some improvements with the task/unit handling. The updated results show a better result (with a small bytes allocation)
benchmark_v4.0-preview2.txt
|
Good day everyone. I've this idea and it's killing me. I've share it and my thought would give me some peace. Maybe, it would be better to add support for IRequest without Unit in v3.2? Also, let's just add analyzer warning to remove the Unit while keeping both versions for while, up until v4.0 release? And completely delete the Unit in that release? I mean, people are using this Package and it's critical change. Wouldn't it be better to give everyone some time to just adapt to the reality? what do you think? |
Implementation for #103