Ejemplo n.º 1
0
 public function testCreateJob()
 {
     $job = new Job($this->job_name, $this->job_data);
     $this->assertNull($job->getId());
     $this->assertEquals($this->job_name, $job->getClassName());
     $this->assertEquals($this->job_data, $job->getArguments());
     $this->assertLessThanOrEqual(new DateTime(), $job->getCreatedAt());
 }
Ejemplo n.º 2
0
 /**
  * @param Job $job
  */
 protected function executeJob($job)
 {
     $this->log('Executing job ' . $job->getId());
     if ($this->runner->runJob($job)) {
         $this->queue->delete($job);
     } else {
         $this->log("Job failed");
         if ($this->queue->countReserves($job) < 3) {
             $this->log("Putting back in queue");
             $this->queue->release($job);
         } else {
             $this->log("Putting job on hold");
             $this->queue->bury($job);
         }
     }
 }
Ejemplo n.º 3
0
 public function countReserves(Job $job)
 {
     $stats = $this->pheanstalk->statsJob($job->getId());
     return $stats->reserves;
 }