-
Notifications
You must be signed in to change notification settings - Fork 247
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
Is it a bad practice for an event handler to depend on a projector completion? #543
Comments
Here's some further explanations about this issue and my software design concerns: I have two aggregates: If an instance of As of now, this workflow is actually done by the event handler of
In order for But if I do that, How would one deal with it? This also raises the question of which state should be the source of truth in a relationship between two aggregates, and which events are responsible for updating relationships projections? |
"It Depends", Yes, avoid dependencies between Projectors (Event Handler) and Processors (Event Handler). That means creating a Processor own its Projections as well. The anti-pattern (especially as the system grows) is to use somebody else Projection. Once again, "It Depends". |
Hi folks,
Following the Conduit sample app design, I wrote an event handler that listens for
EventA
and dispatchesEventB
in response to that event.EventA
should add a record to the persistence layer usingProjectorA
.EventB
should add some records to the persistence layer usingProjectorB
, depending on up-to-date records persisted byProjectorA
.The problem is that, from my understanding, strong consistency doesn't guarantee that the event handler for
EventA
will be executed only whenProjectorA
persisted the associated record.What do you think is the best solution in this situation?
Is this design considered bad because I create a dependency between two handlers (
EventA
handler andProjectorA
)? If so, how would you rewrite this workflow?Should I use the
after_update/3
callback fromcommanded_ecto_projections
in order for me to be sure thatProjectorA
persisted its record?Should I explicitly wait for the completion of
ProjectorA
inside theEventA
handler?The text was updated successfully, but these errors were encountered: