Closed yawaramin closed 6 years ago
The tricky thing is that the parent doesn't know the message type of the faulted child (this allows much easier actor composition). Thus 'msg
is the type of the parent message. It may instead be better to define the supervision policy on the child instead, this will likely require changes to the js, but you're right in that there are a number of use cases which make important to access the message.
My experience with ML is such that I might be missing an obvious avenue of correctly typing the supervision policy, so if you can think of an alternative approach, I'd love to hear it.
@yawaramin I've discussed it with colleagues, and they agree that you have a good point 👍. In the next few days I'll modify the code to have the supervision policy specified on the child instead of the parent.
Supervision policy specified by the child itself is a good idea. It makes it possible for a top-level actor (i.e. a direct child of the actor system) to be supervised also. I haven't looked too much into Nact internals but this decoupled supervision approach will definitely be better. But I'll look through the internals a bit more and get back to you if anything stands out.
@yawaramin v2.0.0 of ReasonNact is out and as promised allows you to specify the supervision policy on the child.
Amazing! I can't wait to try this out on my project :-)
Tried it out, works like a charm! I'll post some more details soon.
In the documentation ( https://nact.io/lesson/reasonml/supervision ), it is mentioned that
However, in the
Nact.rei
interface, the supervision policy type is defined asIt looks like this callback will not get the message that was processed at time of crash. It would be really great to get that message in this callback function, because that would let me send back a meaningful error response from the supervision policy handler back to the calling actor.
You could introduce the message in a backwards-compatible way, as an optional parameter: