示例#1
0
 public function setTubeFromJob(BeanstalkdJob $job)
 {
     $stats = $this->pheanstalk->statsJob($job->getPheanstalkJob());
     $this->tube = $stats->tube;
 }
示例#2
0
 /**
  * Get the number of times the job has been attempted.
  *
  * @return int
  */
 public function attempts()
 {
     $stats = $this->pheanstalk->statsJob($this->job);
     return (int) $stats->reserves;
 }
示例#3
0
 /**
  * @param $jobId
  *
  * @return object|\Pheanstalk\Response
  */
 public function findJob($jobId)
 {
     return $this->connection->statsJob($jobId);
 }
 /**
  * @inheritdoc
  */
 public function waitAndReserve($timeout = null)
 {
     if ($timeout === null) {
         $timeout = $this->defaultTimeout;
     }
     $pheanstalkJob = $this->client->reserveFromTube($this->name, $timeout);
     if ($pheanstalkJob === null || $pheanstalkJob === false) {
         return null;
     }
     $pheanstalkJobStats = $this->client->statsJob($pheanstalkJob);
     $numberOfReleases = isset($pheanstalkJobStats['reserves']) && $pheanstalkJobStats['reserves'] > 0 ? (int) $pheanstalkJobStats['reserves'] - 1 : 0;
     return new Message((string) $pheanstalkJob->getId(), json_decode($pheanstalkJob->getData(), true), $numberOfReleases);
 }