Resque_Worker::workingOn PHP Method

workingOn() public method

Tell Redis which job we're currently working on.
public workingOn ( Resque_Job $job )
$job Resque_Job Resque_Job instance containing the job we're working on.
    public function workingOn(Resque_Job $job)
    {
        $job->worker = $this;
        $this->currentJob = $job;
        $job->updateStatus(Resque_Job_Status::STATUS_RUNNING);
        $data = json_encode(array('queue' => $job->queue, 'run_at' => strftime('%a %b %d %H:%M:%S %Z %Y'), 'payload' => $job->payload));
        Resque::redis()->set('worker:' . $job->worker, $data);
    }

Usage Example

Beispiel #1
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 = Resque_Job::reserve('jobs');
     $this->assertEquals(Resque_Job_Status::STATUS_WAITING, $newJob->getStatus());
 }
All Usage Examples Of Resque_Worker::workingOn