public function unserialize(\Pheanstalk\Job $pheanstalkJob) { $data = json_decode($pheanstalkJob->getData()); $data->data = (array) $data->data; $data->data['_beanstalk_id'] = $pheanstalkJob->getId(); return new Job($data->name, $data->data); }
/** * Scrive un log del job se possibile * * @param int $jobId * @param string $message * @return null */ private function log(Job $job, $message, $severity = LoggerInterface::SEVERITY_INFO) { if (!empty($this->logger)) { $jobId = $job->getId(); $timeString = date('Y-m-d H:i:s'); $msg = "[{$timeString} QueueJob: {$jobId}] {$message}"; $this->logger->log($msg, $severity); } }
public function testExecute() { $args = $this->getCommandArgs(); $job = new Job($args['job'], 'data'); $this->pheanstalk->expects($this->once())->method('peek')->with($job->getId())->will($this->returnValue($job)); $command = $this->application->find('leezy:pheanstalk:peek'); $commandTester = new CommandTester($command); $commandTester->execute($args); $this->assertContains(sprintf('Job id: %d', $job->getId()), $commandTester->getDisplay()); $this->assertContains(sprintf('Data: %s', $job->getData()), $commandTester->getDisplay()); }
public function __call($method, $args) { try { $result = call_user_func_array(array($this->_beanstalk, $method), $args); //Chaining. if ($result instanceof Pheanstalk) { return $this; } //Check for json data. if ($result instanceof Job) { if ($this->isJson($result->getData())) { $result = new Job($result->getId(), json_decode($result->getData())); } } return $result; } catch (ConnectionException $e) { Yii::error($e); return false; } }
/** * Get the job identifier. * * @return string */ public function getJobId() { return $this->job->getId(); }