Created
December 17, 2016 14:28
-
-
Save invasionofsmallcubes/24996d66819e49f60f99083ede31a314 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
Hi, | |
I watched your presentation about CQRS and Erlang at NDC Oslo. | |
Before I ask you something, please now I never used Erlang so it could my | |
lack of knowledge on the language that led me to ask you this question. | |
I have a question about the demo code: | |
` | |
attempt_command({withdraw_money, Amount}, State) -> | |
NewBalance = State#state.balance - Amount, | |
Id = State#state.id, | |
Event = case(NewBalance < 0) of | |
false -> | |
#bank_account_money_withdrawn{id=Id, amount=Amount, | |
new_balance=NewBalance,transaction_date=erlang:localtime()}; | |
true -> | |
#bank_account_payment_declined{id=Id,amount=Amount, | |
transaction_date=erlang:localtime()} | |
end, | |
apply_new_event(Event, State); | |
``` | |
The first line is where you try to withdraw money. How is handled here the concurrency? | |
I mean I can have two concurrent operations on the same bank account but here I don't see | |
this check here. Is the system running all commands sequentially so that state doesn't get corrupted? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment