예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function deregister(QueueInterface $queue)
 {
     $result = $this->adapter->delete($queue);
     if ($result) {
         $this->eventDispatcher->dispatch(ResqueQueueEvents::UNREGISTERED, new QueueEvent($queue));
     }
     return $result;
 }
예제 #2
0
파일: Queue.php 프로젝트: php-resque/resque
 /**
  * {@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;
 }
예제 #3
0
 /**
  * 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));
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }
예제 #6
0
 /**
  * {@inheritDoc}
  */
 public function persist(WorkerInterface $worker)
 {
     $this->adapter->save($worker);
     $this->eventDispatcher->dispatch(ResqueWorkerEvents::PERSISTED, new WorkerEvent($worker));
     return $this;
 }