Пример #1
0
 public function execute(SyrupJob $job)
 {
     parent::execute($job);
     $command = $job->getCommand();
     try {
         // run jobu
         if ($command === 'run') {
             $esJob = new Job();
             $esJob->build($job);
             if (!$this->usePhases($esJob)) {
                 $executor = new Run($this->orchestrationManager, $this->jobManagerFactory, $this->mailer, $this->encryptor, $this->logger, $this->queueFactory);
             } else {
                 $executor = new RunParallel($this->orchestrationManager, $this->jobManagerFactory, $this->mailer, $this->encryptor, $this->logger, $this->queueFactory);
             }
             $executor->setStorageApi($this->storageApi);
             $this->cache[$job->getId()] = $executor;
             return $executor->execute($job);
         }
     } catch (\Exception $e) {
         throw $e;
     }
     throw new \InvalidArgumentException(sprintf('Executor cannot process "%s" jobs.', $job->getCommand()));
 }
Пример #2
0
 /**
  * @param SyrupJob $job
  */
 protected final function validateJob(SyrupJob $job)
 {
     parent::validateJob($job);
     if ($job->getCommand() !== self::COMMAND_NAME) {
         throw new \InvalidArgumentException(sprintf('%s Executor can process only "%s" jobs. "%s" job given', ucfirst(self::COMMAND_NAME), self::COMMAND_NAME, $job->getCommand()));
     }
 }