Last active
January 9, 2016 17:02
-
-
Save damianh/2e287f4b3de8e16b58c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title Command Handling, Pessimistic Concurrency | |
actor User | |
boundary Handler | |
boundary Repository | |
entity BarInstance | |
database EventStore | |
autonumber | |
User -> Handler : Set Foo = 2 on Bar\nwhere version = Y | |
Handler -> Repository : Get Bar | |
Repository -> BarInstance : Create Bar instance | |
activate BarInstance | |
Repository -> EventStore : Get all Bar\nevents from Bar stream | |
Repository -> BarInstance : Apply all Bar events\nto Bar instance | |
Repository -> Handler : Return Bar, version = X | |
group Pessimistic Version Check | |
Handler -> Handler : If Y != X\nthrow Concurrency Exception | |
Handler -> User : Concurrency exception | |
end | |
Handler -> BarInstance : Invoke method Foo | |
note right | |
0 or more events raised by Bar | |
end note | |
Handler -> Repository : Save Bar | |
Repository -> BarInstance : Get events to append | |
deactivate BarInstance | |
group No events to append | |
Repository -> Repository : If events.Count = 0, return | |
Repository -> Handler: Return | |
Handler -> User: Return | |
end | |
Repository -> EventStore : Append events to Bar stream | |
group Concurrency Exception | |
EventStore -> EventStore : If stream version != X\nthrow Concurrency Exception | |
EventStore -> Repository : Concurrency Exception | |
Repository -> Handler : Concurrency Exception | |
Handler -> User : Concurrency Exception | |
end | |
EventStore -> EventStore : Stream appended | |
EventStore -> Repository : Return | |
Repository -> Handler : Return | |
Handler -> User : Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment