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

Add actor lifecycle event 'stopping' #186

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

koola
Copy link

@koola koola commented Feb 14, 2025

This lifecycle event is useful in many scenarios for my usecases.

Included in this PR is a test that covers all the actors lifecycle sequences to ensure proper order.

All other test pass.

@tralafiti
Copy link
Contributor

tralafiti commented Feb 20, 2025

If I see it correctly, the new Stopping event is only sent when poisoning, but not in other cases where the actor would receive a stopped event? So there are cases where an actor received stopping, possible some other messages, and finally stopped. And other cases where it just receives stopped. Hence I find the name at least misleading/confusing.

Could you please describe the use cases you intend to solve with this and update the markdown files?

@koola
Copy link
Author

koola commented Feb 20, 2025

If I see it correctly, the new Stopping event is only sent when poisoning, but not in other cases where the actor would receive a stopped event?

I don't understand your logic here. What other cases? All actors are sent a poison pill (sendPoisonPill) with a boolean graceful flag so the stopping event is raised there.

@tralafiti
Copy link
Contributor

tralafiti commented Feb 20, 2025

For example if something panics within your actor, you receive a Stopped but no Stopping.

@koola
Copy link
Author

koola commented Feb 20, 2025

For example if something panics within your actor, you receive a Stopped but no Stopping.

You have a point. It wasn't included in panic recover as it kinda dupes stopped and was more a hook into poison before the buffer. Have updated to include all and be more faithful to the title.

=== RUN   Test_CleanTrace
Got message type actor.Initialized
Got message type actor.Started
Got message type actor.triggerPanic
Got message type actor.Stopping
Got message type actor.Stopped
2025/02/21 00:05:26 ERROR Actor crashed and restarted pid=foo/4070365677225643757 stack="..." reason=foo restarts=1
Got message type actor.Initialized
Got message type actor.Started
Got message type actor.ActorStartedEvent
Got message type actor.ActorStoppingEvent
Got message type actor.ActorRestartedEvent
stack trace contains panicWrapper at the right line
Got message type actor.ActorInitializedEvent
Got message type actor.ActorStartedEvent
test passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants