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
| private Task AwaitingDebitConfirmation(IContext context) | |
| { | |
| switch (context.Message) | |
| { | |
| case OK _: | |
| await _persistence.PersistEventAsync(new AccountDebited()); | |
| context.SpawnNamed(TryCredit(_to, +_amount), "CreditAttempt"); | |
| break; | |
| //... | |
| } |
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
| public async Task ReceiveAsync(IContext context) | |
| { | |
| switch (context.Message) | |
| { | |
| case Started msg: | |
| _behavior.Become(Starting); | |
| await _persistence.RecoverStateAsync(); | |
| break; | |
| // ... | |
| } |
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
| private void ApplyEvent(Event @event) | |
| { | |
| switch (@event.Data) | |
| { | |
| case TransferStarted msg: | |
| _behavior.Become(AwaitingDebitConfirmation); | |
| break; | |
| case AccountDebited msg: | |
| _behavior.Become(AwaitingCreditConfirmation); | |
| break; |
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
| private void ApplyEvent(Event @event) | |
| { | |
| switch (@event.Data) | |
| { | |
| case TransferStarted msg: | |
| _behavior.Become(AwaitingDebitConfirmation); | |
| break; | |
| // ... other transitions | |
| } | |
| } |
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
| private async Task Starting(IContext context) | |
| { | |
| if (context.Message is Started) | |
| { | |
| context.SpawnNamed(TryDebit(_from, -_amount), "DebitAttempt"); | |
| await _persistence.PersistEventAsync(new TransferStarted()); | |
| } | |
| } |
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
| private Task Starting(IContext context) | |
| { | |
| if (context.Message is Started) | |
| { | |
| context.SpawnNamed(TryDebit(_from, -_amount), "DebitAttempt"); | |
| _behavior.Become(AwaitingDebitConfirmation); | |
| } | |
| } |
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
| case Refused _: | |
| case Terminated _: | |
| _logger.Log("Transfer status unknown. Escalate") | |
| StopAll(context); |
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
| case OK _: | |
| _logger.Log("Transfer failed. System consistent") | |
| StopAll(context); |
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
| private async Task RollingBackDebit(IContext context) | |
| { | |
| switch (context.Message) | |
| { | |
| //... | |
| case OK _: | |
| _logger.Log("Transfer failed. System consistent") | |
| StopAll(context); | |
| break; | |
| case Refused _: |
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
| case Terminated msg: | |
| _logger.Log("Transfer status unknown. Escalate") | |
| StopAll(context); |