コード例 #1
0
        public static IApplicationBuilder StartNode(string[] args, KillRecpientType type)
        {
            //Assemblys.WireUp();
            return(ActorApplication.Create(args)
                   .ConfigureAutoFac(cb =>
            {
                cb.RegisterType <ConsoleAppRoute>().Named <IAppRoute>("default");
                cb.RegisterType <KillHelper>().As <IStartUpAction>();
            })
                   .ConfigurateNode()
                   .ConfigureLogging((context, configuration) =>
            {
                Console.Title = context.HostEnvironment.ApplicationName;

                configuration.WriteTo.ColoredConsole();
            })
                   .ConfigurateAkkaSystem((context, system) =>
            {
                if (type == KillRecpientType.Seed)
                {
                    KillSwitch.Setup(system);
                }
                else
                {
                    KillSwitch.Subscribe(system, type);
                }
            }));
        }
コード例 #2
0
            public KillWatcher(KillRecpientType type)
            {
                Receive <ActorUp>(obs => obs.Do(au => Log.Info("Send ActorUp Back {Name}", au.Actor.Path))
                                  .SubscribeWithStatus(au => au.Actor.Tell(new ActorUp(Self, nameof(KillWatcher)))));

                Receive <RequestRegistration>(obs => obs.Do(_ => Log.Info($"Sending Respond {type}"))
                                              .Select(_ => new RespondRegistration(type))
                                              .ToSender());

                Receive <KillNode>(obs => obs.Do(_ => Log.Info("Leaving Cluster"))
                                   .ToUnit(() => Cluster.Get(Context.System).LeaveAsync()));
            }
コード例 #3
0
        public static IHostBuilder StartNode(this IHostBuilder builder, KillRecpientType type, IpcApplicationType ipcType, Action <IActorApplicationBuilder>?build = null, bool consoleLog = false)
        {
            var masterReady = false;

            if (ipcType != IpcApplicationType.NoIpc)
            {
                masterReady = SharmComunicator.MasterIpcReady(IpcName);
            }
            var ipc = new IpcConnection(masterReady, ipcType,
                                        (s, exception) => LogManager.GetCurrentClassLogger().Error(exception, "Ipc Error: {Info}", s));

            return(builder.ConfigureLogging((context, configuration) =>
            {
                System.Console.Title = context.HostingEnvironment.ApplicationName;
                if (consoleLog)
                {
                    configuration.AddConsole();
                }
            })
                   .ConfigurateNode(ab =>
            {
                ab.ConfigureAutoFac(cb =>
                {
                    cb.RegisterType <NodeAppService>().As <IHostedService>();
                    cb.RegisterType <KillHelper>().As <IStartUpAction>();
                    cb.RegisterInstance(ipc).As <IIpcConnection>();
                })
                .ConfigureAkkaSystem((_, system) =>
                {
                    switch (type)
                    {
                    case KillRecpientType.Seed:
                        KillSwitch.Setup(system);
                        break;

                    default:
                        KillSwitch.Subscribe(system, type);
                        break;
                    }
                });

                build?.Invoke(ab);
            }));
        }
コード例 #4
0
            public KillWatcher(KillRecpientType type)
            {
                Flow <ActorUp>(b =>
                               b.Func(au =>
                {
                    Log.Info("Send ActorUp Back {Name}", au.Actor.Path);
                    return(new ActorUp(Self, "None"));
                })
                               .ToRefFromMsg(au => au.Actor));

                Flow <RequestRegistration>(b =>
                                           b.Func(rr =>
                {
                    Log.Info("Sending Respond {Type}", type);
                    return(new RespondRegistration(type));
                }).ToSender());

                Flow <KillNode>(b =>
                                b.Action(kn =>
                {
                    Log.Info("Leaving Cluster");
                    Cluster.Get(Context.System).LeaveAsync();
                }));
            }
コード例 #5
0
 public RespondRegistration(KillRecpientType recpientType)
 {
     RecpientType = recpientType;
 }
コード例 #6
0
 public static void Subscribe(ActorSystem system, KillRecpientType type)
 {
     Log.LogInformation("SubscribeToEvent Killswitch");
     _switch = system.ActorOf(() => new KillWatcher(type), KillSwitchName);
 }
コード例 #7
0
 public sealed record ActorElement(IActorRef Target,
                                   KillRecpientType RecpientType = KillRecpientType.Unkowen)
 {
コード例 #8
0
 public static IHostBuilder StartNode(string[] args, KillRecpientType type, IpcApplicationType ipcType, Action <IActorApplicationBuilder>?build = null, bool consoleLog = false)
 => StartNode(Host.CreateDefaultBuilder(args), type, ipcType, build, consoleLog);