Exemple #1
0
 protected function makeJob($parentRunId = null, $isV2 = false)
 {
     /** @var Encryptor $encryptor */
     $encryptor = $this->httpClient->getContainer()->get('syrup.encryptor');
     /** @var ObjectEncryptor $objectEncryptor */
     $objectEncryptor = $this->httpClient->getContainer()->get('syrup.object_encryptor');
     // create job
     $tokenData = $this->storageApiClient->verifyToken();
     $componentName = 'queue';
     $jobId = $this->storageApiClient->generateId();
     $job = new Job($objectEncryptor);
     $job->setId($jobId);
     $job->setRunId(is_null($parentRunId) ? $this->storageApiClient->generateId() : $parentRunId . '.' . $this->storageApiClient->generateId());
     $job->setCommand('run');
     $job->setComponent($componentName);
     $job->setLockName('syrup-queue-test');
     if ($parentRunId) {
         $job->setLockName($job->getLockName() . '-child');
     }
     $job->setToken(['id' => $tokenData['id'], 'description' => $tokenData['description'], 'token' => $encryptor->encrypt($this->storageApiClient->getTokenString())]);
     $job->setStatus(Job::STATUS_WAITING);
     $job->setCreatedTime(date('c'));
     $job->setProject(['id' => $tokenData['owner']['id'], 'name' => $tokenData['owner']['name']]);
     if ($isV2) {
         $job->setAttribute('protocol', 'v2');
     }
     return $job;
 }
Exemple #2
0
 public function create($command, array $params = [], $lockName = null)
 {
     $this->storageApiClient = $this->storageApiService->getClient();
     $tokenData = $this->storageApiService->getTokenData();
     $job = new Job($this->objectEncryptor, ['id' => $this->storageApiClient->generateId(), 'runId' => $this->storageApiClient->generateRunId($this->storageApiClient->getRunId()), 'project' => ['id' => $tokenData['owner']['id'], 'name' => $tokenData['owner']['name']], 'token' => ['id' => $tokenData['id'], 'description' => $tokenData['description'], 'token' => $this->objectEncryptor->encrypt($this->storageApiClient->getTokenString())], 'component' => $this->componentName, 'command' => $command, 'params' => $params, 'process' => ['host' => gethostname(), 'pid' => getmypid()], 'nestingLevel' => 0, 'createdTime' => date('c')], null, null, null);
     if ($lockName) {
         $job->setLockName($lockName);
     }
     $componentConfiguration = $this->getComponentConfiguration();
     if (isset($componentConfiguration['flags']) && in_array('encrypt', $componentConfiguration['flags'])) {
         $job->setEncrypted(true);
     }
     return $job;
 }