Skip to content

Commit

Permalink
close akkadotnet#3935 - Akka.Persistence.TCK.Query.TestActor now wait…
Browse files Browse the repository at this point in the history
…s for delete confirmation before replying
  • Loading branch information
Aaronontheweb committed Sep 25, 2019
1 parent 4f984bc commit a249621
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/core/Akka.Persistence.TCK/Query/TestActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Akka.Persistence.TCK.Query
{
internal class TestActor : UntypedPersistentActor
internal class TestActor : UntypedPersistentActor, IWithUnboundedStash
{
public static Props Props(string persistenceId) => Actor.Props.Create(() => new TestActor(persistenceId));

Expand Down Expand Up @@ -43,14 +43,39 @@ protected override void OnCommand(object message)
{
case DeleteCommand delete:
DeleteMessages(delete.ToSequenceNr);
Sender.Tell($"{delete.ToSequenceNr}-deleted");
Become(WhileDeleting(Sender)); // need to wait for delete ACK to return
break;
case string cmd:
var sender = Sender;
Persist(cmd, e => sender.Tell($"{e}-done"));
break;
}
}

protected Receive WhileDeleting(IActorRef originalSender)
{
return message =>
{
switch (message)
{
case DeleteMessagesSuccess success:
originalSender.Tell($"{success.ToSequenceNr}-deleted");
Become(OnCommand);
Stash.UnstashAll();
break;
case DeleteMessagesFailure failure:
originalSender.Tell($"{failure.ToSequenceNr}-deleted-failed");
Become(OnCommand);
Stash.UnstashAll();
break;
default:
Stash.Stash();
break;
}

return true;
};
}
}

public class ColorFruitTagger : IWriteEventAdapter
Expand Down

0 comments on commit a249621

Please sign in to comment.