You are here

public function JobExecutor::call in Apigee Edge 8

Executes a job synchronously.

Parameters

\Drupal\apigee_edge\Job\Job $job: Job to run.

bool $update: Whether to save the job into the database after it ran. Setting this to false means that it is the caller's responsibility to save the job into the database, else the job will be stuck in the "running" state.

Throws

\Exception

Overrides JobExecutorInterface::call

File

src/JobExecutor.php, line 147

Class

JobExecutor
Job executor service.

Namespace

Drupal\apigee_edge

Code

public function call(Job $job, bool $update = TRUE) {
  $this
    ->ensure($job, Job::RUNNING);
  try {
    $result = $job
      ->execute();
    $job
      ->setStatus($result ? Job::IDLE : Job::FINISHED);
  } catch (\Exception $ex) {
    watchdog_exception('apigee_edge_job', $ex);
    $job
      ->recordException($ex);
    $job
      ->setStatus($job
      ->shouldRetry($ex) && $job
      ->consumeRetry() ? Job::RESCHEDULED : Job::FAILED);
  } finally {
    if ($update) {
      $this
        ->save($job);
    }
  }
}