Skip to content

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

Merged
Arkatufus merged 3 commits into
akkadotnet:devfrom
Aaronontheweb:7492-builtin-Restart
Feb 3, 2025
Merged

Akka.Actor: Added built-in IntentionalRestart message to test actor restart behaviors#7493
Arkatufus merged 3 commits into
akkadotnet:devfrom
Aaronontheweb:7492-builtin-Restart

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Jan 31, 2025

Copy link
Copy Markdown
Member

Changes

close #7492

Checklist

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

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Detailed my changes

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.


switch (message)
{
case ActorSelectionMessage selectionMessage:

Copy link
Copy Markdown
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
Copy Markdown
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

@Arkatufus Arkatufus left a comment

Copy link
Copy Markdown
Contributor

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
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