I'm not sure if this is feasible - can I make a single actor a child of many other actors? I can certainly pass in the ref to the other actors but I need the supervision to work in this case too - is this at all possible?
eg here is an example with a typed actor that is a child of system - I want it to be a child of the ConfigResponders in the config router
val zoolittle = Zoolittle(system, None,
Connect(LocalConfigService.zkAddress, LocalConfigService.zkSessionTimeout))
val configRouter = system.actorOf(Props(classOf[ConfigResponder], zoolittle).withRouter(
RoundRobinRouter(nrOfInstances = 5)))
I don't want a bunch of connections to the db in this case.
Thanks in advance!
Each actor is created by exactly one other actor, and that actor is its parent and its supervisor. This is fundamental to the Actor Model and to what supervision means.
If you want an actor to be a child of your ConfigResponders, then each of the ConfigResponders will have to create such a child. If you are just after the supervisorStrategy then have another actor supervise it. Using a Router to install a supervisorStrategy is possible but a little hackish, since normally the supervisor will also have to perform other duties like distributing work or handling the lifecycle of the child.