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); }
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); }
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;