Would you know a nice way in Akka/Scala to add/remove routees to a Broadcaster router?
I have been looking at the Resizer - but does not meet my needs (I cannot see how to explicitly ask the resizer to resize (add routees) and to remove it seems that you need to send a Poison Pill to the actor which is then removed).
So far, I have a router with a list of ActorRef and I send AddRoutee and RemoveRoutee messages....
My business case: I have an actor getting data from the network (via a proxy), and it needs to dispatch this data to independent actors for processing in parallel. Due to the graph nature of the recipients (DAG), the graph can evolve at runtime, vertices/edges being modified, hence the need to add and remove routees
There must be a cleaner way to do this.
Thanks for the pointers.
Example of code I would like Akka to handle:
class MDActor extends Actor {
@volatile var routees = Set[ActorRef]()
def receive = {
case ar: AddRoutee => routees = routees + ar.actorRef
case rr: RemoveRoutee => routees = routees - rr.actorRef
case msg => routees.foreach(r => r forward msg)
}
}