public void Router_RemoveRoute_should_remove_existing_routee_and_leave_the_rest() { var blackHole1 = ActorOf<BlackHoleActor>(); var blackHole2 = ActorOf<BlackHoleActor>(); var router = new Router(new RoundRobinRoutingLogic(), TestActor, blackHole1, blackHole2); var updatedRouter = router.RemoveRoutee(TestActor); updatedRouter.Routees.Count().ShouldBe(2); updatedRouter.Routees.Cast<ActorRefRoutee>().Any(r => ReferenceEquals(r.Actor, blackHole1)).ShouldBe(true); updatedRouter.Routees.Cast<ActorRefRoutee>().Any(r => ReferenceEquals(r.Actor, blackHole2)).ShouldBe(true); }
public RoundRobinLogicActor() { var n = 0; var router = new Router(new RoundRobinRoutingLogic()); Receive<Props>(p => { n++; var c = Context.ActorOf(p, "child-" + n); Context.Watch(c); router = router.AddRoutee(c); }); Receive<Terminated>(terminated => { router = router.RemoveRoutee(terminated.ActorRef); if (!router.Routees.Any()) { Context.Stop(Self); } }); ReceiveAny(other => { router.Route(other, Sender); }); }