Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Akka.Actor: Added built-in IntentionalRestart message to test actor restart behaviors #7493

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Jan 31, 2025

Changes

close #7492

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed my changes

@@ -1264,6 +1264,15 @@ namespace Akka.Actor
public Akka.Actor.IActorRef Watch(Akka.Actor.IActorRef subject) { }
public Akka.Actor.IActorRef WatchWith(Akka.Actor.IActorRef subject, object message) { }
}
public sealed class IntentionalActorRestartException : Akka.Actor.AkkaException
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new IntentionalActorRestartException and an IntentionalRestart auto-received message. I hope the naming makes it obvious why these exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misc-serializer support for IntentionalRestart

TestActor.Tell(mess);

// can't relay the Restart back because that will blow up the TestActor
if (mess is not IntentionalRestart)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't reply back with the IntentionalRestart message because it will crash the TestActor.

@@ -132,27 +132,38 @@ protected internal virtual void AutoReceiveMessage(Envelope envelope)

switch (message)
{
case ActorSelectionMessage selectionMessage:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-organized the switch order for performance reasons - with the most frequent messages appearing first for short-circuiting reasons.

break;
case Identify identify:
HandleIdentity(identify);
case Akka.Actor.IntentionalRestart:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added restart handling here - it just throws an IntentionalActorRestartException

Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Arkatufus Arkatufus merged commit 1f5688d into akkadotnet:dev Feb 3, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Akka.Actor / Akka.TestKit: add a built-in means of forcing actors to restart
2 participants