Commit 7e5d8f6
committed
TotalOrderValue as a summary event
In the past, we've had 2 attempts to calculate total value.
1. Keep everything in one aggregate so that it's able to calculate total. Trigger this via command to Calculate so that the Calculated event is published
2. Keep everything in one aggregate, but publish total value as part of all events that change the state of the aggregate. Total value attribute would exist in many events.
Some calculation also happened in read models.
Both mentioned solutions still co-exist in the codebase.
This new attempt tries to move the calculation to a separate building block.
I call it a process, for the lack of a better word. It could be also called a summary event builder.
https://verraes.net/2019/05/patterns-for-decoupling-distsys-summary-event/
The idea is to subscribe to many events and whenever anything important changes - recalculate and isse TotalOrderValueUpdated.
If this new attempt works, then we could get rid of both previous attempts.
It can also allow us to have smaller aggregates.
One direction it will allow is to consider each Order Line to be an aggregate.
This is still WIP, just to show the direction and grab feedback.1 parent dc19cfb commit 7e5d8f6
File tree
3 files changed
+70
-0
lines changed- rails_application
- app/processes/processes
- test/processes
3 files changed
+70
-0
lines changedLines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
0 commit comments