Esempio n. 1
0
        private DeploymentTargetWorker GetWorkerByTargetId([NotNull] string targetId)
        {
            if (string.IsNullOrWhiteSpace(targetId))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(targetId));
            }

            if (_workers.Length == 0)
            {
                throw new Core.DeployerAppException("There are no registered deployment workers");
            }

            DeploymentTargetWorker workerByTargetId = _workers.SingleOrDefault(worker => worker.TargetId.Equals(targetId, StringComparison.OrdinalIgnoreCase));

            return(workerByTargetId);
        }
Esempio n. 2
0
        public async Task Handle(TargetCreated notification, CancellationToken cancellationToken)
        {
            var worker = new DeploymentTargetWorker(notification.TargetId,
                                                    _logger,
                                                    _mediator,
                                                    _workerConfiguration,
                                                    _timeoutHelper,
                                                    _clock,
                                                    _serviceProvider);

            // TODO remove old worker

            _configurationInstanceHolder.Add(new NamedInstance <DeploymentTargetWorker>(worker, notification.TargetId.TargetId));

            await _mediator.Publish(new WorkerCreated(worker), cancellationToken);
        }
Esempio n. 3
0
        public void Enqueue([NotNull] DeploymentTask deploymentTask)
        {
            if (deploymentTask == null)
            {
                throw new ArgumentNullException(nameof(deploymentTask));
            }

            DeploymentTargetWorker foundWorker = GetWorkerByTargetId(deploymentTask.DeploymentTargetId);

            if (foundWorker is null)
            {
                throw new Core.DeployerAppException(
                          $"Could not find worker for deployment target id {deploymentTask.DeploymentTargetId}");
            }

            foundWorker.Enqueue(deploymentTask);
        }
 public StartWorker(DeploymentTargetWorker worker) => Worker = worker;