public function executeJob(Job $job)
 {
     $worker = $this->container->get($job->getName());
     if (!$worker instanceof Worker) {
         throw new InvalidWorkerException("The worker {$job->getName()} is not an instance of " . Worker::class);
     }
     $worker->execute($job->getArguments());
 }
 /**
  * Remove a job, you should call this when you have finished processing a job
  *
  * @param $job
  * @throws WrongJobException
  * @throws NoSuchJobException
  */
 public function delete(Job $job)
 {
     $this->info('Deleting job', ['name' => $job->getName()]);
 }
 /**
  * Called when a job failed
  *
  * @param Job $job
  * @param \Exception $exception
  */
 protected function failedJob(Job $job, \Exception $exception)
 {
     if ($this->logger) {
         $context = ['name' => $job->getName(), 'arguments' => $job->getArguments(), 'message' => $exception->getMessage(), 'retryable' => !$exception instanceof UnrecoverableJobException];
         if ($p = $exception->getPrevious()) {
             $context['cause'] = $p->getMessage();
         }
         $this->logger->error('Job failed', $context);
     }
     $this->eventDispatcher && $this->eventDispatcher->dispatch(self::JOB_FAILED_EVENT, new FailedJobEvent($job, $exception));
 }