/// <summary> /// Subscribe to diagnostics info. Accesses repository to update metadata (status, errors etc.) of operations. /// </summary> public static void Listen() { _eventRegistry.Register <DiagnosticsResponseEvent>(Exchanges.Diagnostics); _eventBus.Subscribe((DiagnosticsResponseEvent @event) => { using (IServiceScope scope = Services.CreateScope()) { _OperationRequestRepository = scope.ServiceProvider.GetRequiredService <AnalyticsOperationRequestRepository>(); _OperationRequestRepository.Update(@event.Operation); _OperationRequestRepository.SaveChanges(); } }); }
/// <summary> /// Execute operation. Publishes event, that contains AnalyticsOperation for analytical modules. /// </summary> /// <param name="operation"></param> public void ExecuteOperation(UserAnalyticsOperation operation) { _operationRequestRepository.Add(operation); _operationRequestRepository.SaveChanges(); TimeSeriesAnalysisRequestEvent @event = new TimeSeriesAnalysisRequestEvent(operation); string routingKey = _analyticsRegistry.GetQueue(operation.OperationName); if (routingKey != null) { _eventBus.PublishToTopic(@event, routingKey); } else { throw new InvalidRequestException("no such operation"); // not sure if it is right exception } }