static void Main(string[] args) { var localActorConfiguration = AppConfigActorConfiguration.Load(); var localActor = new RpcActor(localActorConfiguration); var helloService = new HelloService(localActor, new CountableRateLimiter()); var calcService = new CalcService(localActor, new CountableRateLimiter()); var orderService = new OrderService(localActor, new CountableRateLimiter()); var orderEventClient = new OrderEventClient(localActor); localActor.RegisterRpcHandler(helloService); localActor.RegisterRpcHandler(calcService); localActor.RegisterRpcHandler(orderService); localActor.RegisterRpcHandler(orderEventClient); var directoryConfiguration = AppConfigCenterActorDirectoryConfiguration.Load(); var directory = new CenterActorDirectory(directoryConfiguration); localActor.Bootup(directory); while (true) { try { string text = Console.ReadLine().ToLowerInvariant(); if (text == "quit" || text == "exit") { break; } else if (text == "reconnect") { localActor.Shutdown(); directory = new CenterActorDirectory(directoryConfiguration); localActor.Bootup(directory); } else if (Regex.Match(text, @"^notify(\d*)$").Success) { var match = Regex.Match(text, @"notify(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { NotifyOrderDelivered(orderEventClient); } } else { _log.WarnFormat("Cannot parse the operation for input [{0}].", text); } } catch (Exception ex) { _log.Error(ex.Message, ex); } } localActor.Shutdown(); }
static void Main(string[] args) { var localActorConfiguration = AppConfigActorConfiguration.Load(); var localActor = new RpcActor(localActorConfiguration); var helloClient = new HelloClient(localActor); var calcClient = new CalcClient(localActor); var orderClient = new OrderClient(localActor); var orderEventService = new OrderEventService(localActor); localActor.RegisterRpcHandler(helloClient); localActor.RegisterRpcHandler(calcClient); localActor.RegisterRpcHandler(orderClient); localActor.RegisterRpcHandler(orderEventService); var directoryConfiguration = AppConfigCenterActorDirectoryConfiguration.Load(); var directory = new CenterActorDirectory(directoryConfiguration); localActor.Bootup(directory); while (true) { try { string text = Console.ReadLine().ToLowerInvariant().Trim(); if (text == "quit" || text == "exit") { break; } else if (text == "reconnect") { localActor.Shutdown(); directory = new CenterActorDirectory(directoryConfiguration); localActor.Bootup(directory); } else if (Regex.Match(text, @"^hello(\d*)$").Success) { var match = Regex.Match(text, @"^hello(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { Hello(helloClient); } } else if (Regex.Match(text, @"^add(\d*)$").Success) { var match = Regex.Match(text, @"^add(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { Add(calcClient); } } else if (Regex.Match(text, @"^order(\d*)$").Success) { var match = Regex.Match(text, @"order(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { PlaceOrder(orderClient); } } else if (Regex.Match(text, @"^hello(\d+)x(\d+)$").Success) { var match = Regex.Match(text, @"^hello(\d+)x(\d+)$"); int totalCalls = int.Parse(match.Groups[1].Value); int threadCount = int.Parse(match.Groups[2].Value); Hello10000MultiThreading(helloClient, totalCalls, threadCount); } else if (Regex.Match(text, @"^add(\d+)x(\d+)$").Success) { var match = Regex.Match(text, @"^add(\d+)x(\d+)$"); int totalCalls = int.Parse(match.Groups[1].Value); int threadCount = int.Parse(match.Groups[2].Value); Add10000MultiThreading(calcClient, totalCalls, threadCount); } else { _log.WarnFormat("Cannot parse the operation for input [{0}].", text); } } catch (Exception ex) { _log.Error(ex.Message, ex); } } localActor.Shutdown(); }