public function getCurrentJob() { $job = $this->worker->job(); if (!$job) { return null; } $job = new \Resque_Job($job['queue'], $job['payload']); return $job->getInstance(); }
public function __construct($queue, $payload, $serviceManager = null) { if ($serviceManager !== null) { $this->setServiceManager($serviceManager); } parent::__construct($queue, $payload); }
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()); }
/** * Reserve and return the next available job in the specified queue. * * @param string $queue Queue to fetch next available job from. * @return Resque_Job Instance of Resque_Job to be processed, false if none or error. */ public static function reserve($queue) { require_once dirname(__FILE__) . '/Resque/Job.php'; return Resque_Job::reserve($queue); }
public function testJobWithTearDownCallbackFiresTearDown() { $payload = array('class' => 'Test_Job_With_TearDown', 'args' => array('somevar', 'somevar2')); $job = new Resque_Job('jobs', $payload); $job->perform(); $this->assertTrue(Test_Job_With_TearDown::$called); }
/** * Reserve and return the next available job in the specified queue. * * @param string $queue Queue to fetch next available job from. * @return Resque_Job Instance of Resque_Job to be processed, false if none or error. */ public static function reserve($queue) { return Resque_Job::reserve($queue); }
/** * Tell Redis which job we're currently working on. * * @param object $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); }
public function testDoNotUseFactoryToGetInstance() { $payload = array('class' => 'Some_Job_Class', 'args' => array(array())); $job = new Resque_Job('jobs', $payload); $factory = $this->getMock('Resque_Job_FactoryInterface'); $testJob = $this->getMock('Resque_JobInterface'); $factory->expects(self::never())->method('create')->will(self::returnValue($testJob)); $instance = $job->getInstance(); $this->assertInstanceOf('Resque_JobInterface', $instance); }