public ContainersMonitoringServiceFactory(ILogger <ContainersMonitoringServiceFactory> logger, ILoggerFactory loggerFactory, DockerClientFactory dockerClientFactory, GlobalCancellationToken globalCancellation, CommandsExecutorFactory commandsExecutorFactory, EventsBus eventsBus) { this.logger = logger; this.loggerFactory = loggerFactory; this.dockerClientFactory = dockerClientFactory; this.globalCancellation = globalCancellation; this.commandsExecutorFactory = commandsExecutorFactory; this.eventsBus = eventsBus; }
public async Task PaymentRegisteredNotification_Test() { var paymentRegisteredNotificationHandler = new PaymentRegisteredNotificationHandler(EventsBus); var meetingGroupPaymentRegisterId = new MeetingGroupPaymentRegisterId(Guid.NewGuid()); var dateTo = new DateTime(2020, 1, 31); var notification = new PaymentRegisteredNotification(new PaymentRegisteredDomainEvent(meetingGroupPaymentRegisterId, dateTo), Guid.NewGuid()); await paymentRegisteredNotificationHandler.Handle(notification, CancellationToken.None); var paymentRegisteredIntegrationEvent = EventsBus.GetLastPublishedEvent <PaymentRegisteredIntegrationEvent>(); Assert.That(paymentRegisteredIntegrationEvent.MeetingGroupPaymentRegisterId, Is.EqualTo(meetingGroupPaymentRegisterId.Value)); Assert.That(paymentRegisteredIntegrationEvent.DateTo, Is.EqualTo(dateTo)); }
public void EventsBusTest() { //Arrange var @event = Substitute.For <IEvent>(); var handler1 = Substitute.For <IHandleEvents <IEvent> >(); var handler2 = Substitute.For <IHandleEvents <IEvent> >(); var bus = new EventsBus(x => new List <IHandleEvents> { handler1, handler2 }); //Run bus.Send(@event); //Assert handler1.Received().Handle(@event); handler2.Received().Handle(@event); }
static async Task Main() { // NA PODSTAWIE //https://devstyle.pl/2016/11/10/cqrsdi-implementacja-w-c-i-autofac/ // MIGRATION // dotnet ef migrations add Init // RUN // docker run -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d dnhsoft/mysql-utf8 // dotnet ef database update var eventHandlerRegistrar = new HandlerRegistrar <IEventHandler>(); eventHandlerRegistrar.Register <PersonSaved>(new PersonListEventsHandler()); eventHandlerRegistrar.Register <AddressSaved>(new PersonListEventsHandler()); eventHandlerRegistrar.Register <PersonSaved>(new PersonDetailsEventHandler()); var eventBus = new EventsBus(eventHandlerRegistrar); var commandHandlerRegistrar = new HandlerRegistrar <ICommandHandler>(); commandHandlerRegistrar.Register <SavePerson>(new SavePersonCommandHandler(eventBus)); commandHandlerRegistrar.Register <SaveAddress>(new SaveAddressCommandHandler(eventBus)); var commandBus = new CommandBus(commandHandlerRegistrar); Console.WriteLine("Saving person..."); await commandBus.Send(new SavePerson("Jan", "Kowalski")); Console.WriteLine("Saving addresses..."); await commandBus.Send(new SaveAddress(1, "Bielsko-Biała", "43-300", "Willowa", "2", AddressType.Main)); await commandBus.Send(new SaveAddress(1, "Bielsko-Biała", "43-300", "Bystrzańska", "100")); await commandBus.Send(new SaveAddress(1, "Bielsko-Biała", "43-300", "Rynek", "10")); Console.WriteLine("Saving person..."); await commandBus.Send(new SavePerson("Adam", "Nowak")); await commandBus.Send(new SaveAddress(2, "Katowice", "43-300", "Mikołowska", "222c", AddressType.Main)); Console.WriteLine("Data saved"); }
public ContainersMonitoringService(ILogger logger, string groupName, ContainersGroupConfiguration configuration, DockerClientFactory dockerClientFactory, GlobalCancellationToken globalCancellation, CommandsExecutorFactory commandsExecutorFactory, EventsBus eventsBus) { this.logger = logger; this.groupName = groupName; this.configuration = configuration; this.dockerClientFactory = dockerClientFactory; this.globalCancellation = globalCancellation; this.commandsExecutorFactory = commandsExecutorFactory; this.eventsBus = eventsBus; this.listParameters = new ContainersListParameters() { All = true, Filters = ComposeFilter(configuration) }; }
protected override void OnStart() { Print("Initializing screener local state."); seriesD1 = new Dictionary <string, MarketSeries>(); seriesH4 = new Dictionary <string, MarketSeries>(); seriesH1 = new Dictionary <string, MarketSeries>(); seriesM5 = new Dictionary <string, MarketSeries>(); atr_D1 = new Dictionary <string, AverageTrueRange>(); atr_H4 = new Dictionary <string, AverageTrueRange>(); atr_H1 = new Dictionary <string, AverageTrueRange>(); atr_M5 = new Dictionary <string, AverageTrueRange>(); mm200_D1 = new Dictionary <string, ExponentialMovingAverage>(); mm200_H4 = new Dictionary <string, ExponentialMovingAverage>(); mm200_H1 = new Dictionary <string, ExponentialMovingAverage>(); mm200_M5 = new Dictionary <string, ExponentialMovingAverage>(); mm55_D1 = new Dictionary <string, ExponentialMovingAverage>(); mm55_H4 = new Dictionary <string, ExponentialMovingAverage>(); mm55_H1 = new Dictionary <string, ExponentialMovingAverage>(); mm55_M5 = new Dictionary <string, ExponentialMovingAverage>(); mm8_D1 = new Dictionary <string, ExponentialMovingAverage>(); mm8_H4 = new Dictionary <string, ExponentialMovingAverage>(); mm8_H1 = new Dictionary <string, ExponentialMovingAverage>(); mm8_M5 = new Dictionary <string, ExponentialMovingAverage>(); macd_D1 = new Dictionary <string, MacdCrossOver>(); macd_H4 = new Dictionary <string, MacdCrossOver>(); macd_H1 = new Dictionary <string, MacdCrossOver>(); macd_M5 = new Dictionary <string, MacdCrossOver>(); state = new State(); Bus = new EventsBus("tcp://*:8888"); foreach (var sym in symbols) { Print("Initializing data for {0}", sym); // Initialize Indicators var lseriesD1 = MarketData.GetSeries(sym, TimeFrame.Daily); var lseriesH4 = MarketData.GetSeries(sym, TimeFrame.Hour4); var lseriesH1 = MarketData.GetSeries(sym, TimeFrame.Hour); var lseriesM5 = MarketData.GetSeries(sym, TimeFrame.Minute5); atr_D1[sym] = Indicators.AverageTrueRange(lseriesD1, 14, MovingAverageType.Exponential); atr_H4[sym] = Indicators.AverageTrueRange(lseriesH4, 14, MovingAverageType.Exponential); atr_H1[sym] = Indicators.AverageTrueRange(lseriesH1, 14, MovingAverageType.Exponential); atr_M5[sym] = Indicators.AverageTrueRange(lseriesM5, 14, MovingAverageType.Exponential); mm200_D1[sym] = Indicators.ExponentialMovingAverage(lseriesD1.Close, 200); mm200_H4[sym] = Indicators.ExponentialMovingAverage(lseriesH4.Close, 200); mm200_H1[sym] = Indicators.ExponentialMovingAverage(lseriesH1.Close, 200); mm200_M5[sym] = Indicators.ExponentialMovingAverage(lseriesM5.Close, 200); mm55_D1[sym] = Indicators.ExponentialMovingAverage(lseriesD1.Close, 55); mm55_H4[sym] = Indicators.ExponentialMovingAverage(lseriesH4.Close, 55); mm55_H1[sym] = Indicators.ExponentialMovingAverage(lseriesH1.Close, 55); mm55_M5[sym] = Indicators.ExponentialMovingAverage(lseriesM5.Close, 55); mm8_D1[sym] = Indicators.ExponentialMovingAverage(lseriesD1.Close, 8); mm8_H4[sym] = Indicators.ExponentialMovingAverage(lseriesH4.Close, 8); mm8_H1[sym] = Indicators.ExponentialMovingAverage(lseriesH1.Close, 8); mm8_M5[sym] = Indicators.ExponentialMovingAverage(lseriesM5.Close, 8); macd_D1[sym] = Indicators.MacdCrossOver(lseriesD1.Close, 26, 12, 9); macd_H4[sym] = Indicators.MacdCrossOver(lseriesH4.Close, 26, 12, 9); macd_H1[sym] = Indicators.MacdCrossOver(lseriesH1.Close, 26, 12, 9); macd_M5[sym] = Indicators.MacdCrossOver(lseriesM5.Close, 26, 12, 9); seriesD1[sym] = lseriesD1; seriesH4[sym] = lseriesH4; seriesH1[sym] = lseriesH1; seriesM5[sym] = lseriesM5; state.AddAsset(sym); } UpdateTiming(); soundPaths = new Dictionary <string, string>(3) { { "PB", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-1.wav" }, { "MMX", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-4.wav" }, { "VCN", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-3.wav" } }; Print("Initialization finished."); if (EnableEventsBus) { Print("Starting event bus."); Bus.Start(); } Bus.Emit(state.ToJson()); using (StreamWriter sw = new StreamWriter(@"C:\Users\Andrey\Desktop\json.txt")) { sw.Write(state.ToJson()); } Render(); }