/** * {@inheritDoc} */ public function deregister(QueueInterface $queue) { $result = $this->adapter->delete($queue); if ($result) { $this->eventDispatcher->dispatch(ResqueQueueEvents::UNREGISTERED, new QueueEvent($queue)); } return $result; }
/** * {@inheritDoc} */ public function dequeue() { $job = $this->storage->dequeue($this); if (!$job) { return null; } if ($job instanceof OriginQueueAwareInterface) { $job->setOriginQueue($this); } $this->eventDispatcher->dispatch(ResqueQueueEvents::JOB_POPPED, new QueueJobEvent($this, $job)); return $job; }
/** * Handle failed job * * @param JobInterface $job The job that failed. * @param \Exception $exception The reason the job failed. */ protected function handleFailedJob(JobInterface $job, \Exception $exception) { if ($job instanceof TrackableJobInterface) { $job->setState(JobInterface::STATE_FAILED); } $this->getLogger()->error('Perform failure on {job}, {message}', array('job' => $job, 'message' => $exception->getMessage(), 'exception' => $exception)); $this->eventDispatcher->dispatch(ResqueJobEvents::FAILED, new JobFailedEvent($job, $exception, $this)); }
function it_offloads_worker_persist_to_adapter(WorkerRegistryAdapterInterface $adapter, EventDispatcherInterface $eventDispatcher, WorkerInterface $worker) { $eventDispatcher->dispatch(ResqueWorkerEvents::PERSISTED, Argument::any())->shouldBeCalled(); $adapter->save($worker)->shouldBeCalled(1); $this->persist($worker)->shouldReturn($this); }
function it_dequeues_a_job(QueueStorageInterface $storage, EventDispatcherInterface $eventDispatcher, JobInterface $job) { $storage->dequeue($this)->shouldBeCalled()->willReturn($job); $eventDispatcher->dispatch(ResqueQueueEvents::JOB_POPPED, Argument::type('Resque\\Component\\Queue\\Event\\QueueJobEvent')); $this->dequeue()->shouldReturn($job); }
/** * {@inheritDoc} */ public function persist(WorkerInterface $worker) { $this->adapter->save($worker); $this->eventDispatcher->dispatch(ResqueWorkerEvents::PERSISTED, new WorkerEvent($worker)); return $this; }