Skip to content

Commit 371819a

Browse files
committed
updates README
- adds image in chapter Optimistic Concurreny Control - fixes a typo - changed 'backend instances' to 'instances of this application' - adds warning admonition box to a potential risk
1 parent 13c020f commit 371819a

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ Event store is used as a write database, and SQL or NoSQL database as a read dat
183183
### <a id="3-6"></a>Event handlers
184184

185185
Commands generate events.
186-
Event processing is done by **event handles**.
186+
Event processing is done by **event handlers**.
187187
As a part of event processing, we may need to update projections,
188188
send a message to a message broker, or make an API call.
189189

190-
There are two types of event handles: **synchronous** and **asynchronous**.
190+
There are two types of event handlers: **synchronous** and **asynchronous**.
191191

192192
Storing the write model and read model in the same database allows for transactional updates of the read model.
193193
Each time we append a new event, the projection is updated **synchronously** in the same transaction.
@@ -264,6 +264,8 @@ Appending an event operation consists of 2 SQL statements in a single transactio
264264
```
265265
`pg_current_xact_id()` returns the current transaction's ID. The need for this will be explained later.
266266
267+
![Optimistic Concurrency Control](img/event-sourcing-concurrency.svg)
268+
267269
### <a id="4-4"></a>Snapshotting
268270
269271
On every *nth* event insert an aggregate state (snapshot) to the `ES_AGGREGATE_SNAPSHOT` table specifying the version
@@ -338,7 +340,7 @@ New events are processed by polling the `ES_EVENT` table.
338340

339341
![Transactional outbox pattern with subscriptions](img/transactional-outbox-2.svg)
340342

341-
Since multiple backend instances can run in parallel,
343+
Since multiple instances of this application can run in parallel,
342344
we need to ensure that any processing only affects the event once.
343345
We don't want more than one event handler instance to handle the same event.
344346
@@ -481,6 +483,8 @@ This mechanism is used by default as more efficient.
481483
After restarting the backend, existing subscriptions will only process new events after the last processed event
482484
and not everything from the first one.
483485
486+
> [!WARNING]
487+
> Critical content demanding immediate user attention due to potential risks.
484488
New subscriptions (event handlers) in the first poll will read and process all events.
485489
Be careful, if there are too many events, they may take a long time to process.
486490

img/event-sourcing-concurrency.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@startuml
2+
3+
scale max 1024 width
4+
scale max 800 height
5+
6+
skinparam defaultTextAlignment center
7+
skinparam componentStyle rectangle
8+
9+
skinparam database {
10+
BorderColor Grey
11+
}
12+
13+
component "Order Service" as orderService
14+
15+
database "Database" {
16+
17+
rectangle "Transaction" #line.dashed {
18+
19+
component aggregateTbl [
20+
**ES_AGGREGATE** Table
21+
|= ""ID"" |= ""VERSION"" | | | |
22+
| | | | | |
23+
| | | | | |
24+
]
25+
26+
component eventTbl [
27+
**ES_EVENT** Table
28+
|= ""ID"" | | | | |
29+
| 1 | | | | |
30+
| 2 | | | | |
31+
| 3 | | | | |
32+
]
33+
}
34+
}
35+
36+
aggregateTbl -[hidden]> eventTbl
37+
38+
orderService --> aggregateTbl: **1.** UPDATE\lversion
39+
orderService --> eventTbl: **2.** INSERT
40+
41+
@enduml

0 commit comments

Comments
 (0)