Example #1
0
        public override Host Build()
        {
            if (ServiceBuilders.Count > 1)
            {
                throw new HostConfigurationException("A shelf can only have one service configured");
            }

            ServiceBuilder builder = ServiceBuilders.Single();

            _log.DebugFormat("[Shelf:{0}] Building Service: {1}", Description.Name, builder.Name);

            var controllerFactory = new ServiceControllerFactory();
            ActorFactory <IServiceController> factory = controllerFactory.CreateFactory(inbox =>
            {
                var publish = new PublishChannel(_channel, inbox);

                IServiceController service = builder.Build(inbox, publish);

                return(service);
            });

            ActorInstance instance = factory.GetActor();

            _channel.Connect(x => { x.AddChannel(instance); });

            // this creates the state machine instance in the shelf and tells the servicecontroller
            // to create the service
            instance.Send(new CreateService(Description.Name));

            return(new ShelfHost(instance));
        }
Example #2
0
 /// <summary>
 /// Sends a Kill message to an actor instance
 /// </summary>
 /// <param name="instance">The actor instance</param>
 public static void Kill(this ActorInstance instance)
 {
     instance.Send <Kill>(new KillImpl());
 }
Example #3
0
 /// <summary>
 /// Sends an Exit message to an actor instance
 /// </summary>
 /// <param name="instance">The actor instance</param>
 public static void Exit(this ActorInstance instance)
 {
     instance.Send <Exit>(new ExitImpl());
 }