Skip to content

Instantly share code, notes, and snippets.

@tomliversidge
Created June 24, 2017 13:59
Show Gist options
  • Save tomliversidge/01115bc231d1426b2b4af3270daed0bc to your computer and use it in GitHub Desktop.
Save tomliversidge/01115bc231d1426b2b4af3270daed0bc to your computer and use it in GitHub Desktop.
Saga 4.2
private readonly Dictionary<PID, object> _processedMessages = new Dictionary<PID, object>();
public Task ReceiveAsync(IContext context)
{
switch (context.Message)
{
case Credit msg when _processedMessages.ContainsKey(msg.ReplyTo):
replyTo.Tell(_processedMessages[replyTo]);
return Actor.Done;
case Credit msg:
_balance += amount;
_processedMessages.Add(replyTo, new OK());
replyTo.Tell(new OK());
return Actor.Done;
//...
}
return Actor.Done;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment