Esempio n. 1
0
 protected function setupWorkerRegistry()
 {
     if (null === $this->workerRegistry) {
         $this->workerRegistry = new WorkerRegistry($this->workerRegistryAdapter, $this->eventDispatcher, $this->workerFactory);
     }
     $workerRegistry = $this->workerRegistry;
     // When a job performed, remove it from the worker, also update processed numbers.
     $this->eventDispatcher->addListener(\Resque\Component\Job\ResqueJobEvents::PERFORMED, function (\Resque\Component\Worker\Event\WorkerJobEvent $event) use($workerRegistry) {
         $workerRegistry->persist($event->getWorker());
     });
 }
Esempio n. 2
0
 public function testWorkerRecoversFromChildDirtyExit()
 {
     return $this->markTestIncomplete();
     $queue = new RedisQueue($this->redis);
     $queue->setName('jobs');
     $job = new Job('Resque\\Component\\Job\\Tests\\Jobs\\DirtyExit');
     $queue->push($job);
     $test = $this;
     $eventDispatcher = new EventDispatcher();
     $callbackTriggered = false;
     $eventDispatcher->addListener(ResqueJobEvents::FAILED, function ($event) use(&$callbackTriggered, $test) {
         $callbackTriggered = true;
         $test->assertInstanceOf('Resque\\Component\\Job\\Exception\\DirtyExitException', $event->getException());
     });
     $this->worker->work(0);
     $this->assertTrue($callbackTriggered);
 }