Created
June 24, 2017 14:02
-
-
Save tomliversidge/64caf8ad51692fe2c9049a8dc2d4a90e to your computer and use it in GitHub Desktop.
Saga 5.2
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 Task ReceiveAsync(IContext context) | |
{ | |
switch (context.Message) | |
{ | |
//... | |
case Started _: | |
var random = new Random(); | |
_inMemoryProvider = new InMemoryProvider(); | |
for (int i = 1; i <= _numberOfIterations; i++) | |
{ | |
int j = i; | |
var fromAccount = CreateAccount($"FromAccount{j}", random); | |
var toAccount = CreateAccount($"ToAccount{j}", random); | |
var transferProps = Actor.FromProducer(() => new TransferProcess(fromAccount, toAccount, 10, | |
_inMemoryProvider, $"Transfer Process {j}", random, _uptime)) | |
.WithChildSupervisorStrategy( | |
new OneForOneStrategy((pid, reason) => SupervisorDirective.Restart, _retryAttempts, | |
null)); | |
var transfer = context.SpawnNamed(transferProps, $"Transfer Process {j}"); | |
_transfers.Add(transfer); | |
} | |
break; | |
} | |
return Actor.Done; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment