/** * @return StorageApiEvent */ private function prepareEvent() { $event = new StorageApiEvent(); $event->setComponent(KeboolaOrchestratorBundle::SYRUP_COMPONENT_NAME)->setRunId($this->job->getRunId()); if ($this->stopwatchEvent) { $event->setDuration($this->stopwatchEvent->stop()->getDuration() / 1000); } return $event; }
public function getJobStatus($url, Elasticsearch\Job $job, Encryptor $encryptor) { $timeout = 2; return $this->get($url, array('config' => array('curl' => array(CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0)), 'headers' => array('X-StorageApi-Token' => $encryptor->decrypt($job->getToken()), 'X-KBC-RunId' => $job->getRunId(), 'X-User-Agent', KeboolaOrchestratorBundle::SYRUP_COMPONENT_NAME . " - JobExecutor"), 'timeout' => 60 * $timeout)); // handling curl errors // $request->getEmitter()->on('error', function (ErrorEvent $e) use ($timeout) { // $curlError = $e->getTransferInfo('curl_result'); // if ($curlError == 28) { // throw new Exception\JobRuntimeException(sprintf('Task polling timeout after %d minutes', $timeout)); // } // }); }