🏗️ refactor(architecture): move events from write slices packages to dedicated one for between slices contracts #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change caused by LinkedIn discussion:
https://www.linkedin.com/feed/update/urn:li:activity:7295062961356771328?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7295062961356771328%2C7295089102633263104%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287295089102633263104%2Curn%3Ali%3Aactivity%3A7295062961356771328%29
I've given it more thought recently, and indeed events extracted from slices can be more flexible (to do not couple them to their sourced command slice, but treat as API between slices).
Especially in cases where the same event can be triggered by two different commands (although this doesn't happen very frequently).
I have a case in the project, where I think I should refactor handling the
RecruitCreature
. It should result in two eventsCreatureRecruited
andAvailableCreaturesChanged
instead of just the first one. Then in event handlers to reduce available creatures, I will just handleAvailableCreaturesChanged
instead of both.What I would potentially modify is to extract the events separately, as a contract (system backbone) between slices, while keeping the rest as it was. The Aggregate and Commands would stay in the write package, as they're only shared between write slices. Rest API, external consumers and commands will be also in the same package, do not spread one slice through "layers" like "domain/application".
Of course, everything I mean in the scope of a single Bounded Context.