Created
January 9, 2016 17:07
-
-
Save damianh/79433b2ac513c3b3f026 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, Optimistic Concurrency | |
actor User | |
boundary Handler | |
boundary Repository | |
entity BarInstance | |
database EventStore | |
autonumber | |
User -> Handler : Set Foo = 2 where\nOriginalFoo = 1 on Bar | |
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 Optimistic Check | |
Handler -> BarInstance : Invoke method Foo | |
BarInstance -> BarInstance : If OriginalFoo != 1\nthrow Concurrency Exception | |
BarInstance -> Repository : Concurrency Exception | |
Repository -> Handler : Concurrency Exception | |
Handler -> User : Concurrency Exception | |
end | |
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