Grain parent child supervision
Arttii opened this issue · comments
Hi,
I was wondering if it's possible to start several children in a grain, which themselves are grain. I am specifically wondering if there is a parent child supervision type mechanism when using grains in this way.
The background is that I am starting several grains, but a parent grain drives them. In case that shuts down, I would like to propagate the shutdown to the children. I am doing this because in one case the actors are indeed grains and will run somewhere in the cluster, but in a specific case it's desirable for them to run together and be supervised by one parent actor.
Is there away to do this, or should I implement everything as direct actors instead? Thanks!
EDIT:
It seems if I do something like this:
props := actor.PropsFromProducer(func() actor.Actor {
return &grain.Actor{
Timeout: 0,
}
})
pid, _ := ctx.SpawnNamed(props,Id)
client := getNamespacedGrainGrainClient(cl, ctx.Self().Id,Id)
From the parent grain, where getNamespacedGrainGrainClient
resolved the client to the same identity, then i can force the grain to run as a child of the parent grain.
Is this an anti-pattern?
Sorry for late response here.
No, there is no way to apply supervision for grains. or have any type of parent-child relation between grains.
Grains are fully managed by the IdentityLookupProvider used, eg. disthash.