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 msg: | |
| _behavior.Become(RollingBackDebit) | |
| context.SpawnNamed(TryCredit(_from, +_amount), "RollbackDebit"); |
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 msg: | |
| _logger.Log("Success!") | |
| 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 AwaitingCreditConfirmation(IContext context) | |
| { | |
| switch (context.Message) | |
| { | |
| //... | |
| case OK msg: | |
| _logger.Log("Success!") | |
| StopAll(context); | |
| break; | |
| case Refused msg: |
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 _: | |
| _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 Refused _: | |
| _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
| case OK _: | |
| _behavior.Become(AwaitingCreditConfirmation); | |
| context.SpawnNamed(TryCredit(_to, +_amount), "CreditAttempt"); |
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 _: | |
| _behavior.Become(AwaitingCreditConfirmation); | |
| context.SpawnNamed(TryCredit(_to, +_amount), "CreditAttempt"); | |
| break; | |
| case Refused _: | |
| _logger.Log("Transfer failed. System consistent") |
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"); | |
| _behavior.Become(AwaitingDebitConfirmation); | |
| } | |
| } | |
| private Props TryDebit(PID targetActor, decimal amount) => Actor |
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) | |
| { | |
| await _behavior.ReceiveAsync(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
| class AccountProxy : IActor | |
| { | |
| private readonly PID _account; | |
| private readonly Func<PID, object> _createMessage; | |
| public AccountProxy(PID account, Func<PID, object> createMessage) | |
| { | |
| _account = account; | |
| _createMessage = createMessage; | |
| } |