scala - Dynamically add/remove routees to a router actor -
would know nice way in akka/scala add/remove routees broadcaster router?
i have been looking @ resizer - not meet needs (i cannot see how explicitly ask resizer resize (add routees) , remove seems need send poison pill actor removed).
so far, have router list of actorref , send addroutee , removeroutee messages....
my business case: have actor getting data network (via proxy), , needs dispatch data independent actors processing in parallel. due graph nature of recipients (dag), graph can evolve @ runtime, vertices/edges being modified, hence need add , remove routees
there must cleaner way this.
thanks pointers.
example of code akka 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) } }
whenever find lacking feature in router time start thinking in other direction: wrong actor code present? unless need route more few million messages per second (which unlikely given description) such actor precisely right solution. routers specialized construct should not used substitute; use them when meet requirements , have benchmarked normal actor not suffice.
Comments
Post a Comment