예제 #1
0
파일: Program.cs 프로젝트: fzf003/EventFly
        public static async Task Main(string[] args)
        {
            //Get configuration file using EventFly's defaults as fallback
            var path       = Environment.CurrentDirectory;
            var configPath = Path.Combine(path, "seed.conf");
            var config     = ConfigurationFactory.ParseString(File.ReadAllText(configPath))
                             .WithFallback(EventFlyClusteringDefaultSettings.DefaultConfig());
            var clustername = config.GetString("akka.cluster.name");

            //Create actor system
            var actorSystem = ActorSystem.Create(clustername, config);

            Console.WriteLine("EventFly.Examples.Seed Running");

            var quit = false;

            while (!quit)
            {
                Console.Write("\rPress Q to Quit.         ");
                var key = Console.ReadLine();
                quit = key?.ToUpper() == "Q";
            }

            //Shut down the local actor system
            await actorSystem.Terminate();

            Console.WriteLine("EventFly.Examples.Seed Exiting.");
        }
예제 #2
0
        public static async Task Main(string[] args)
        {
            //Get configuration file using EventFly's defaults as fallback
            var path       = Environment.CurrentDirectory;
            var configPath = Path.Combine(path, "worker.conf");
            var baseConfig = ConfigurationFactory.ParseString(File.ReadAllText(configPath));

            //specified amount of workers running on their own thread
            var amountOfWorkers = 1;

            //Create several workers with each worker port will be 6001, 6002,...
            var actorSystems = new List <ActorSystem>();

            foreach (var worker in Enumerable.Range(1, amountOfWorkers + 1))
            {
                //Create worker with port 700X
                var config = ConfigurationFactory.ParseString($"akka.remote.dot-netty.tcp.port = 700{worker}");
                config = config
                         .WithFallback(baseConfig)
                         .WithFallback(EventFlyClusteringDefaultSettings.DefaultConfig());
                var clustername = config.GetString("akka.cluster.name");
                var actorSystem = ActorSystem.Create(clustername, config);
                actorSystems.Add(actorSystem);


                Cluster.Get(actorSystem).RegisterOnMemberUp(() =>
                {
                    //Start the aggregate cluster when the actorsystem is part of a cluster.
                    //all requests being proxied to this cluster will be sent here to be processed.
                    StartUserAccountCluster(actorSystem);
                });
            }

            Console.WriteLine("EventFly.Examples.Workers Running");

            var quit = false;

            while (!quit)
            {
                Console.Write("\rPress Q to Quit.         ");
                var key = Console.ReadLine();
                quit = key?.ToUpper() == "Q";
            }

            //Shut down all the local actor systems
            foreach (var actorsystem in actorSystems)
            {
                await actorsystem.Terminate();
            }
            Console.WriteLine("EventFly.Examples.Workers Exiting.");
        }
예제 #3
0
파일: Program.cs 프로젝트: fzf003/EventFly
        public static async Task Main(string[] args)
        {
            //Get configuration file using EventFly's defaults as fallback
            var path       = Environment.CurrentDirectory;
            var configPath = Path.Combine(path, "client.conf");
            var config     = ConfigurationFactory.ParseString(File.ReadAllText(configPath))
                             .WithFallback(EventFlyClusteringDefaultSettings.DefaultConfig());

            //Create actor system
            var clustername        = config.GetString("akka.cluster.name");
            var shardProxyRoleName = config.GetString("akka.cluster.singleton-proxy.role");
            var actorSystem        = ActorSystem.Create(clustername, config);

            StartApplication(actorSystem, shardProxyRoleName);
            await actorSystem.WhenTerminated;

            Console.WriteLine("EventFly.Examples.ClusterClient Exiting.");
        }