static void Main() { Console.WriteLine("Starting server..."); using (var system = new ActorsSystem()) using (StatsService.Run(system.Monitor)) { var listener = QueuedActor.Of(new ConnectionListener(Addresses.Listener, system)); system.SubscribeByAddress(listener); var connectionWorkers = QueuedActor.Of(mailbox1 => new RoundRobinActor( id: Addresses.ConnectionWorkers, workerFactory: () => QueuedActor.Of(mailbox2 => new ClientConnectionWorker(system, mailbox2), system.Monitor), degreeOfParallelism: 2, system: system, mailBox: mailbox1)); system.SubscribeByAddress(connectionWorkers); system.Monitor.MonitorActor(connectionWorkers); system.Send(new StartListening()); Console.WriteLine("Server started"); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } Console.WriteLine("Finished"); }
static void Main(string[] args) { using (var system = new ActorsSystem()) { var trader = QueuedActor.Of(new StopLossTrader(Addresses.TraderAddress, system)); system.SubscribeByAddress(trader); var orderProcessor = QueuedActor.Of(new OrderProcessor(Addresses.OrderProcessorAddress, system)); system.SubscribeByAddress(orderProcessor); var market = QueuedActor.Of(new Market(ActorId.GenerateNew(), system)); system.SubscribeByAddress(market); Console.WriteLine("Press any key to stop"); Console.ReadLine(); } }
private static void Main(string[] args) { Console.ReadLine(); using (var system = new ActorsSystem()) { var generator = new Generator(ActorId.GenerateNew(), system); system.SubscribeByAddress(generator); var connectionWorkers = QueuedActor.Of(mailbox1 => new RoundRobinActor( id: Addresses.TcpWritersDispatcher, workerFactory: () => QueuedActor.Of(mailbox2 => new TcpWriter(ActorId.GenerateNew(), system, mailbox2), system.Monitor), degreeOfParallelism: 5, system: system, mailBox: mailbox1)); system.SubscribeByAddress(connectionWorkers); system.Monitor.MonitorActor(connectionWorkers); var diskWriter = new DiskWriter(Addresses.DiskWriter); var queuedDiskWriter = QueuedActor.Of(diskWriter); system.SubscribeByAddress(queuedDiskWriter); system.Monitor.MonitorActor(queuedDiskWriter); var stopwatch = new Stopwatch(); stopwatch.Start(); system.Send(new GenerateNextMessage(generator.Id)); Console.WriteLine("Stresser running"); //Console.WriteLine("Press any key to stop..."); //Console.ReadLine(); diskWriter.AllJobDone.Wait(); stopwatch.Stop(); Console.WriteLine("Speed: {0} msg/sec", ((float)diskWriter.TotalMessagesProcessed) / stopwatch.ElapsedMilliseconds * 1000); } }
public void when_prices_start_going_below_threshold_trader_sells_position() { var schedulerMock = new SchedulerMock(); using (var system = new ActorsSystem(schedulerMock)) { var trader = new StopLossTrader(ActorId.GenerateNew(), system); system.SubscribeByAddress(trader); system.Send(new PriceChanged(trader.Id, 100m, Guid.Parse("00000000-0000-0000-0000-000000000001"))); system.Send(new PriceChanged(trader.Id, 110m, Guid.Parse("00000000-0000-0000-0000-000000000002"))); system.Send(new RemoveFrom15(trader.Id, Guid.Parse("00000000-0000-0000-0000-000000000001"))); system.Send(new PriceChanged(trader.Id, 90m, Guid.Parse("00000000-0000-0000-0000-000000000003"))); system.Send(new RemoveFrom30(trader.Id, Guid.Parse("00000000-0000-0000-0000-000000000001"))); system.Send(new RemoveFrom15(trader.Id, Guid.Parse("00000000-0000-0000-0000-000000000001"))); system.Send(new RemoveFrom30(trader.Id, Guid.Parse("00000000-0000-0000-0000-000000000002"))); Check.That(system.DeadSink).Contains(new Sell(Addresses.OrderProcessorAddress, trader.Id.Value, 90m)); } }