@param AbstractJob|Job $job

@throws ResultException
484193
protected function doJob(AbstractJob $job)
    {
        $this->validateJobParams($job);

        try {
            $resultData['response'] = $this->sendMessage($job);
        } catch (\Exception $ex) {
            throw new ResultException(ResultException::ERROR_TRANSPORT);
        }

        throw new ResultException(ResultException::R_SUCCESS, $resultData);
    }
1254426
public JobReport execute(Job job) {
        try {
            return executorService.submit(job).get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException("Unable to execute job " + job.getName(), e);
        }
    }
655076
protected function executeJob(Job $job): ?\Throwable
    {
        try {
            $this->jobExecutor->executeJob($job, $this->retryLimit);
        } catch (\Throwable $e) {
            return $e;
        }

        return null;
    }
34169
public function save(AbstractJob $job)
    {

        $data = $job->getData();
        if (!$job->isStored()) {
            $job->setId(uniqid());
        }

        $this->redis->set($this->namespace . $job->getId(), json_encode($data));

        return true;
    }
605017
public function start(Job $job)
    {
        $jobData = new JobData();

        if ($this->exec) {
            $jobDir = $this->_getJobDirectory($job);
            $logFile = realpath($this->getDirectory()) . '/run.log';
            $lockFile = $this->_lockJob($jobDir);

            if ($lockFile) {
                // $jobdir = str_replace("/", DIRECTORY_SEPARATOR, $jobDir);

                $jobData->lockFile = $lockFile;
                $jobData->job = $job;
                $jobData->jobDir = $jobDir;

                $this->runningJobs[spl_object_hash($job)] = $jobData;

                $data = $job->getData();
                $data['___class'] = get_class($job);

                file_put_contents("$jobDir/in.serialize", serialize($data));

                $cmd = $this->getCmd('"'.realpath(__DIR__ . "/../../bin/AsynchronousJobsRun.php") . "\" $jobDir >> $logFile");
                if (substr(php_uname(), 0, 7) == "Windows") {
                    $WshShell = new \COM("WScript.Shell");
                    $WshShell->Run("$cmd /C dir /S %windir%", 0, false);
                } else {
                    exec($cmd . " &");
                }

            } else {
                $this->pendingJobs[] = $job;
            }
        }else {
            $job->run();
            $job->end($jobData);
        }
    }
1245907
public function enqueueAt(int $at, Job $job): void
    {
        $data = $job->getPayload();

        $data['s_time'] = time();

        $key = sprintf('%s:%s', self::AT_QUEUE_NAME, $at);
        $this->client->rpush($key, [json_encode($data)]);
        $this->client->zadd(self::AT_QUEUE_NAME, [$at => $at]);
    }
438484
public function job_fail($handle, $job, $result) {

        $message = "($handle) Failed Job: $job: ".$result->getMessage();

        $this->log($message, GearmanManager::LOG_LEVEL_WORKER_INFO);

        $this->log_result($handle, $result);
    }
252527
private function pushExecutedJob(Job $job)
    {
        $this->executedJobs[] = $job;

        $compiled = $job->compile();

        // If callable, log the string Closure
        if (is_callable($compiled)) {
            $compiled = 'Closure';
        }

        $this->addSchedulerVerboseOutput("Executing {$compiled}");

        return $job;
    }
1301191
public function workingOn(Job &$job)
    {
        $this->job = $job;
        $job->setWorker($this);

        Event::fire(Event::WORKER_WORKING_ON, array($this, $job));

        $this->redis->hmset(self::redisKey($this), array(
            'job_id'      => $job->getId(),
            'job_started' => microtime(true)
        ));
    }
307365
protected function validateJobParams(Job $job)
    {
        if (empty($job->getToken())) {
            throw new ResultException(ResultException::ERROR_PARAM_TOKEN);
        }

        if (empty($job->getRoom())) {
            throw new ResultException(ResultException::ERROR_PARAM_ROOM);
        }

        if (empty($job->getFrom())) {
            throw new ResultException(ResultException::ERROR_PARAM_FROM);
        }

        if (empty($job->getMsg())) {
            throw new ResultException(ResultException::ERROR_PARAM_MSG);
        }

    }
83691
public function call(Job $job, array $data)
    {
        $payload = $this->crypt->decrypt(
            $data['closure']
        );

        $closure = unserialize($payload);

        call_user_func($closure, $job);
    }
1123066
public function run(JobInterface $job)
    {
        parent::run($job);

        if (!($job instanceof MappedJob)) {
            return $this;
        }


        $job->setResult(
            $this->mapper->map(
                $job->getEntityRepository(),
                $job->getMappedClass(),
                $job->getResult()
            )
        );

        // allow chaining
        return $this;
    }
24252
private function execute(Job $job, JobRunner $runner, $callback) {
        $runner->runIt($job, $callback);
    }
1242705
function uploadJob(Job $job): void {
    if (!$job->getRepoToken() && !$job->getServiceName())
      throw new \InvalidArgumentException('The job does not meet the requirements.');

    $uri = UriResolver::resolve($this->getEndPoint(), new Uri('jobs'));
    $body = new MultipartStream([[
      'contents' => json_encode($job, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
      'filename' => 'coveralls.json',
      'name' => 'json_file'
    ]]);

    $headers = [
      'content-length' => $body->getSize(),
      'content-type' => "multipart/form-data; boundary={$body->getBoundary()}"
    ];

    try {
      $request = new Request('POST', $uri, $headers, $body);
      $this->emit(new RequestEvent($request));

      $response = (new HTTPClient())->send($request);
      $this->emit(new ResponseEvent($request, $response));
    }

    catch (\Throwable $e) {
      throw new ClientException('An error occurred while uploading the report.', $uri, $e);
    }
  }
458246
protected function findJobHandler(Job $job)
    {
        foreach ($this->handlers as $type => $handler) {
            if ($job->getHandlerType() == $type) {
                return $handler;
            }
        }
        
        throw new \OutOfBoundsException(\sprintf('Job handler "%s" not found for job %s', $job->getHandlerType(), $job->getId()));
    }
1243134
protected function setFinishData(array &$result, array &$job)
    {
        $result['message'] = $job['message']['finish'];

        $this->setFinishDataErrors($result, $job);
        $this->setFinishDataNoErrors($result, $job);
    }
586332
protected function doJob(AbstractJob $job)
    {
        $this->validateJobParams($job);

        $resultData = SmsWorker::buildResultDataDefault(__NAMESPACE__);

        try {
            $transport = $this->getTransport();
            $transport->sendSMS($job->getSender(), $job->getRecipient(), $job->getText());

            $response = $transport->getResponse();
            $resultData[SmsWorker::P_RESULT_DATA_SUCCESS] = (count($response['errors']) == 0);
            $resultData[SmsWorker::P_RESULT_DATA_VENDOR_ID] = $response['id'];
            $resultData[SmsWorker::P_RESULT_DATA_ERRORS] = $response['errors'];

            $job->addDebug(['vendor_response' => $response]);

        } catch (\Exception $ex) {
            $job->addDebug(['exception' => $ex->getMessage()]);
            throw new ResultException(ResultException::ERROR_TRANSPORT);
        }


        if (false === $resultData[SmsWorker::P_RESULT_DATA_SUCCESS]) {

            if (!$job->isSync()) {
                // redirect result for new root gateway class
                $gatewayClass = static::getConfig(SmsWorker::GATEWAY_DISPATCH_CLASS);
                $job->addDebug(['set_gateway' => $gatewayClass]);
                $job->setWorkerClass($gatewayClass)->save();
                throw new ResultException(ResultException::RETRY_GATEWAY_DISPATCH_CLASS);
            }

            throw new ResultException(ResultException::R_FAILURE, $resultData);
        }

        throw new ResultException(ResultException::R_SUCCESS, $resultData);
    }