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

[Question] How to stop an Actor? #27

Open
fermuch opened this issue Feb 4, 2022 · 4 comments
Open

[Question] How to stop an Actor? #27

fermuch opened this issue Feb 4, 2022 · 4 comments

Comments

@fermuch
Copy link

fermuch commented Feb 4, 2022

Suppose I have a system where I spawn an actor to manage each item in a list.
Once the item is removed from the list, how can I stop the Actor?

  • tarant version: 3.1.1
@gpicron
Copy link

gpicron commented Jan 18, 2023

any answer ?

@fermuch
Copy link
Author

fermuch commented Jan 18, 2023

Sadly not. I had to create a special message requesting the Actor to "die". Once the actor receives that message, it kills itself.

I would love to have an official way to kill actors, tho'.

@kmruiz
Copy link
Member

kmruiz commented Jan 21, 2023

Hi @fermuch,

apologies for the late response.

You are totally right, there is no specific way to stop a single actor right now, as there would be different strategies to do it and we (@kanekotic and I) were designing which would be the best way. Can I ask you what would you consider the most efficient way to stop an actor to gather your feedback?

Questions we were trying to answer:

  • What happens with the mailbox when an actor is stopped? Should we process pending messages? What happens when a pending message is then failing?
  • What happens when an actor is stopping and receives new messages? Should they go to a dead letter? Or notify the sender that the actor does not exist anymore?

Thanks a lot and sorry for the late response.

@fermuch
Copy link
Author

fermuch commented Jan 23, 2023

What happens with the mailbox when an actor is stopped? Should we process pending messages? What happens when a pending message is then failing?

I think there should be two ways to stopping an actor: request and force.

REQUESTING

  • The actor should decide if it must stop (a callback with a boolean response?)
  • The actor should stop getting new messages (trying to append to a stopped actor should raise an error).
  • The actor should process every message it had right until the stop message.
  • A last message should be sent, so the actor can clean its resources.

FORCING

  • The actor is stopped immediately.
  • All pending messages in the mailbox are discarded.

Note: in both cases, the requester (sender) of the stop message should have the possibility to wait for the actor to be fully stopped, so a new actor can be spawned with the same details.


By separating into these two, I think all use cases are solved. By requesting, you give the actor time to process its pending messages. And, if you need, you can kill it immediately.

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

No branches or pull requests

3 participants