public function execute(CommittedJob $job, LogProvider $logProvider) { $r = new \ReflectionClass($job->getImplementation()); $task = $r->newInstance(); if ($task instanceof LoggerAwareInterface) { $task->setLogger($logProvider->getLogger()); } $task->perform(...$job->getArguments()); }
private function workOn(CommittedJob $job, HandlerInterface $jobHandler) { try { $this->logger->notice("Starting work on {$job->getId()}"); $logProvider = new LogProvider($this->logger, $jobHandler); $this->jobExecutor->execute($job, $logProvider); $this->metro->succeed($job->getId()); $this->logger->notice("Finished work on {$job->getId()}"); } catch (\Exception $e) { $this->logException($e, $job->getId()); $this->metro->fail($job->getId()); } }
/** * @return CommittedJob|null */ public function get() { if ($job = $this->redis->get($this->key)) { if ($array = Encoder::decode($job)) { return CommittedJob::jsonUnserialize($array); } } return null; }