lunatic-rs
lunatic-rs copied to clipboard
Update message ABI
Since distributed send
can fail I've updated the signatures to return error codes.
Related to https://github.com/lunatic-solutions/lunatic/pull/135
I think we should update all the process/mailbox/protocol APIs to reflect error codes, now functions just fail silently
(as they used to). send
API is used quite extensively in the library, I'm not familiar enough to change it all yet and
could use some help. The documentation states that there are no guaranties that the message will be delivered, but that
does not mean no errors are reported.
LunaticError
can be used in most cases, but users might want to know some specific cases, e.g. when a node connection is lost.
I'm unsure if it's worth supporting error reporting on send
. It significantly complicates the API, but we still can't reliably handle failure. What kind of error would be reported back to the guest? Something like "the node temporarily disconnected"?
I chose to not report errors, because erlang doesn't report errors back. Even if you send a message to a process on the local node that doesn't exist. It would be easy to know if it exists, but because we want to provide a transparent API for local and remote processes and we can't tell if the process exists on the other node I decided to follow erlang's approach.
This forces users to return a success message if they need to know that the other side got it. That way they get a much more resilient system for free. They don't need to update their code once they move from local to remote processes. Also many network errors (even with TCP) are silent. You only get a confirmation that the OS kernel took your buffer, but not that it was ever actually sent out. That's why I believe that erlang's approach is right here from a fault-tolerance perspective. Don't let users rely on error handling if you can't consistently report the error.