TriggerQueue SaveRandomTriggerQueue(ITriggersCatalog triggerCatalog, Guid triggerId) { var randomizer = new Random(); var source = "TestResource" + randomizer.Next(1, 10000); var queue = "TestQueueName" + randomizer.Next(1, 10000); var workflowName = "TestWorkflow" + randomizer.Next(1, 10000); var mockResource = new Mock <IResource>(); mockResource.Setup(resource => resource.ResourceName).Returns(source); mockResource.Setup(resource => resource.ResourceID).Returns(Guid.NewGuid()); var triggerQueueEvent = new TriggerQueue { TriggerId = triggerId, QueueSourceId = mockResource.Object.ResourceID, QueueName = queue, WorkflowName = workflowName }; triggerCatalog.SaveTriggerQueue(triggerQueueEvent); return(triggerQueueEvent); }
public WorkerContext(IArgs processArgs, IResourceCatalogProxy resourceCatalogProxy, ITriggersCatalog triggerCatalog) { var catalog = triggerCatalog; _path = TriggersCatalog.PathFromResourceId(processArgs.TriggerId); _serverUri = processArgs.ServerEndpoint; _triggerQueue = catalog.LoadQueueTriggerFromFile(_path); _resourceCatalogProxy = resourceCatalogProxy; }
public QueueWorkerMonitor(IProcessFactory processFactory, IQueueConfigLoader queueConfigLoader, ITriggersCatalog triggersCatalog, IChildProcessTracker childProcessTracker) { _childProcessTracker = childProcessTracker; _processFactory = processFactory; _queueConfigLoader = queueConfigLoader; triggersCatalog.OnChanged += (triggerId) => { try { var configs = _queueConfigLoader.Configs; var config = configs.First(o => o.Id == triggerId); WorkerDeleted(config.Id); WorkerCreated(config.Id); } catch (Exception e) { Dev2Logger.Warn(e.Message, ""); } }; triggersCatalog.OnDeleted += WorkerDeleted; triggersCatalog.OnCreated += WorkerCreated; }
public IWorkerContext New(IArgs processArgs, IResourceCatalogProxy resourceCatalogProxy, ITriggersCatalog triggerCatalog, IFilePath filePath) { return(new WorkerContext(processArgs, resourceCatalogProxy, triggerCatalog, filePath)); }
private IWorkerContext TryGetConfig(IResourceCatalogProxy resourceCatalogProxy, ITriggersCatalog triggersCatalog, IFilePath filePath) { var triggerId = _options.TriggerId; IWorkerContext workerContext; try { workerContext = _workerContextFactory.New(_options, resourceCatalogProxy, triggersCatalog, filePath); } catch (Exception ex) { _writer.WriteLine("failed."); _writer.Write(ex.Message); _logger.Error(ex.Message, triggerId); return(null); } return(workerContext); }
private Implementation.Config SetupQueueWorkerImplementationConfings(out Mock <IWriter> mockWriter, out Mock <IExecutionLogPublisher> mockExecutionLogPublisher, IEnvironmentConnection environmentConnection, IResourceCatalogProxy resourceCatalogProxy, IWorkerContextFactory workerContextFactory, ITriggersCatalog triggersCatalog, IFilePath filePath, IFileSystemWatcherFactory fileSystemWatcherFactory, IQueueWorkerImplementationFactory queueWorkerImplementationFactory, IEnvironmentWrapper environmentWrapper) { mockWriter = new Mock <IWriter>(); mockExecutionLogPublisher = new Mock <IExecutionLogPublisher>(); var mockExecutionLoggerFactory = new Mock <IExecutionLoggerFactory>(); mockExecutionLoggerFactory.Setup(o => o.New(It.IsAny <ISerializer>(), It.IsAny <IWebSocketPool>())).Returns(mockExecutionLogPublisher.Object); var mockResourceCatalogProxyFactory = new Mock <IResourceCatalogProxyFactory>(); mockResourceCatalogProxyFactory.Setup(o => o.New(environmentConnection)).Returns(resourceCatalogProxy); var mockServerProxyFactory = new Mock <IServerProxyFactory>(); mockServerProxyFactory.Setup(o => o.New(new Uri("https://localhost:3143/"))).Returns(environmentConnection); var mockTriggersCatalogFactory = new Mock <ITriggersCatalogFactory>(); mockTriggersCatalogFactory.Setup(o => o.New()).Returns(triggersCatalog); var implConfig = new Implementation.Config { EnvironmentWrapper = environmentWrapper, ExecutionLoggerFactory = mockExecutionLoggerFactory.Object, FilePath = filePath, FileSystemWatcherFactory = fileSystemWatcherFactory, QueueWorkerImplementationFactory = queueWorkerImplementationFactory, ResourceCatalogProxyFactory = mockResourceCatalogProxyFactory.Object, ServerProxyFactory = mockServerProxyFactory.Object, TriggersCatalogFactory = mockTriggersCatalogFactory.Object, WorkerContextFactory = workerContextFactory, Writer = mockWriter.Object }; return(implConfig); }