-
Notifications
You must be signed in to change notification settings - Fork 36
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
Remove stopping
and the entire KeepRunning
construct
#64
Comments
This does make sense to me, I think. I really like how this simplifies control flow and general usage - less ways to do the same thing. You can emulate preventing an actor from shutdown from |
This would supercede and close #58, right? |
Yes. |
Yep, I had a similar thought. I think moving more of this functionality into messages is a good thing. I've also been contemplating the idea of making the |
How would replacing started work? Would each address of the actor be made to send a start message? |
I was thinking of something like this (assuming #62): impl Context {
pub async fn run<A>(mut self, actor: A) -> A::Stop where A: Actor + Handler<Started, ()> {
self.address.send(Started).await;
}
} But I just realized that that doesn't work because we obviously can't receive messages until we are in the actual loop within the context. |
Cool. If you are on-board with that, I will have a go at removing the function and all the code associated with |
Sure, and thanks! 👍 |
Solved by #82 . Note that KeepRunning was kept for attach_stream but when this is moved to an extension crate it will go there too. |
Whilst working on #51, I came to the conclusion that I'd like to propose to remove the
stopping
function and with it the concept ofKeepRunning
.The reasons why I consider it problematic are:
KeepRunning::StopAll
, we may terminate actors without them being able to prevent that. It seems weird that a single actor can intervene shutdown (when initiated viaContext#stop
) but other actors cannot.Context#stop
. It seems much cleaner to use a supervisor pattern (see https://github.com/itchysats/itchysats/blob/master/xtras/src/supervisor.rs for example) to restart an actor when it was shut down. With the recent addition ofActor#Stop
, this is actually super easy and clean to implement.The current features of
stopping
andKeepRunning
can still be achieved through other means:Context
can be done with a custom message and thenotify_all
functionRemoving
stopping
andKeepRunning
would IMO also simplify a lot of the state management inContext
and make #51 easier to implement / finish. What do you think?The text was updated successfully, but these errors were encountered: