-
Notifications
You must be signed in to change notification settings - Fork 69
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
Receive functions that return results #125
Comments
the main problem with panics in rust is that they crash the entire programme, instead of just a single thread. |
That's not true. Panics are (by default) contained within their thread. Within the same thread they can be isolated using |
Panics are handled in-thread and specifically with regards to Riker within the executor. If an actor panics the actor's mailbox is suspended and the parent supervisor determines how to handle the panic, as per the supervision strategy defined. The panic is isolated and no errors are leaked. If the supervisor decides to restart the child then a new actor of the same type, at the same path is started. The restarted actor follows the same life cycle as any new actor, including fresh state. The message that caused the actor to panic and any other values that the actor owned are removed from memory. Remaining messages in the mailbox will continue to be processed. Technically it would be possible to return a future of a result that could be extracted. However, this breaks the actor model. It would mean that, in addition to an actor acting upon its expected message types at a mailbox level, it would also be acting upon out-of-bounds messages, in this case a As a concrete example, if you are modeling an ecommerce payments flow with actors, you'd having a hierarchy like:
If the customer is paying with card the manager (e.g. This is the same reason why the |
this reads like something that should be, almost verbatim, in our documentation |
It also should be documented that the supervision doesn't work if compiled with Edit: |
There is not really another way apart from letting the respective scheduler thread die and starting a new one. |
in all the examples I've seen so far, i feel like this could also help model #103. |
This is also more of a question since I'm still figuring things out and wanted to know more about the error handling practices of Riker. Wouldn't it be better if receive functions can return a
Result
? e.g. ananyhow::Result
or Riker special result with errors that give hints of severity to know if the message should be retried, the actor restarted or just go to the dead letters queue? I know there is a preference in this pattern for letting things fail but on the ergonomics side it's like writing old rust with tons ofunwrap
/expect
and I'm still to early in the game to even know how to handle those panics later 😅The text was updated successfully, but these errors were encountered: