-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Make actor.Stop
respect the given exit reason
#88
base: main
Are you sure you want to change the base?
Conversation
actor.Stop
respect the given exit reason
2147e40
to
a510de5
Compare
I noticed afterwards, that there's some overlap between this and #86 Sorry for not spotting it earlier. I'll take a closer look at what was done there later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Couple questions inline
case reason { | ||
Abnormal(reason) -> process.send_abnormal_exit(process.self(), reason) | ||
Killed -> process.kill(process.self()) | ||
_ -> Nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No catch all patterns ever please 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced it with Stop(_)
👍
I also removed the dependency to gleam-lang/erlang#65 / gleam-lang/erlang#67, even though one of the tests is a bit wonky now 🤷
@@ -404,10 +409,10 @@ fn initialise_actor( | |||
loop(self) | |||
} | |||
|
|||
// The init failed. Exit with an error. | |||
// The init failed. Send the reason back to the parent, but exit normally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we now exit normally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed_init_test
would otherwise fail with the test process being killed. It's also what I'd assume to be correct based on the docs:
Failed(String)
The actor has failed to initialise. The actor shuts down and an error is returned to the parent process.
"shuts down" implies a clean exit to me.
The reason the test wasn't failing before is that exit_process
didn't respect the reason given to it.
If we don't want a clean exit, then I think actor.Failed
shouldn't exist, or it should at least have clearer documentation (similar reasoning to what I said here).
a510de5
to
c726c63
Compare
Resolves #89
The actor would stop with
Normal
before this.