AddRoutee() public method

Create a new instance with one more routee and the same RoutingLogic.
public AddRoutee ( ActorSelection routee ) : Router
routee Akka.Actor.ActorSelection
return Router
Ejemplo n.º 1
0
        public void Router_AddRoute_should_not_add_same_routee()
        {
            var router = new Router(new RoundRobinRoutingLogic(), TestActor);

            var updatedRouter = router.AddRoutee(TestActor);
            updatedRouter.Routees.Count().ShouldBe(1);
            updatedRouter.Routees.First().AsInstanceOf<ActorRefRoutee>().Actor.ShouldBe(TestActor);
        }
Ejemplo n.º 2
0
 public void Router_AddRoute_should_add_new_routee()
 {
     var router = new Router(new RoundRobinRoutingLogic(), TestActor);
     var blackHole = ActorOf<BlackHoleActor>();
     var updatedRouter = router.AddRoutee(blackHole);
     updatedRouter.Routees.Count().ShouldBe(2);
     updatedRouter.Routees.Cast<ActorRefRoutee>().Any(r => ReferenceEquals(r.Actor, TestActor)).ShouldBe(true);
     updatedRouter.Routees.Cast<ActorRefRoutee>().Any(r => ReferenceEquals(r.Actor, blackHole)).ShouldBe(true);
 }
Ejemplo n.º 3
0
            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);
                });
            }