示例#1
0
 /**
  * Attempt to find a job from the top of one of the queues for this worker.
  *
  * @return object|boolean Instance of Job if a job is found, false if not.
  */
 public function reserve()
 {
     $queues = $this->queues();
     if (!is_array($queues)) {
         return null;
     }
     foreach ($queues as $queue) {
         $this->log('Checking ' . $queue);
         $job = Job::reserve($queue);
         if ($job) {
             $this->log('Found job on ' . $queue);
             return $job;
         }
     }
     return false;
 }
示例#2
0
 public function testRecreatedJobWithTrackingStillTracksStatus()
 {
     $originalToken = Resque::enqueue('jobs', '\\Test_Job', null, true);
     $job = $this->worker->reserve();
     // Mark this job as being worked on to ensure that the new status is still
     // waiting.
     $this->worker->workingOn($job);
     // Now recreate it
     $newToken = $job->recreate();
     // Make sure we've got a new job returned
     $this->assertNotEquals($originalToken, $newToken);
     // Now check the status of the new job
     $newJob = Job::reserve('jobs');
     $this->assertEquals(Status::STATUS_WAITING, $newJob->getStatus());
 }