protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $queue = $this->queueFactory->createQueue($input->getArgument('queue'));
     if ($input->isInteractive()) {
         if (!$output->confirm(sprintf(static::CONFIRM_MSG, $queue->getName()), false)) {
             return;
         }
     }
     $count = $this->queueRegistry->deregister($queue);
     $output->success('Deleted queue "' . $queue->getName() . '"');
     if ($count) {
         $output->note('Removed ' . $count . ' jobs.');
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $queue = $this->queueFactory->createQueue($input->getArgument('queue'));
     //        if ($input->isInteractive()) {
     //            if (!$output->confirm(sprintf('you sure?', $queue->getName()), false)) {
     //                return;
     //            }
     //        }
     $this->queueRegistry->register($queue);
     // @todo should this be here?
     $job = new Job($input->getArgument('target'));
     // @todo remove new Job.
     if ($queue->enqueue($job)) {
         $output->success('Enqueued job "' . $job->getJobClass() . '" with arguments, to queue "' . $queue->getName() . '"');
     }
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function createWorkerFromId($workerId)
 {
     if (false === strpos($workerId, ":")) {
         return null;
     }
     list($hostname, $pid, $queues) = explode(':', $workerId, 3);
     $queues = explode(',', $queues);
     if (!$queues) {
         throw new ResqueRuntimeException(sprintf("Invalid worker ID \"%s\"", $workerId));
     }
     $worker = new Worker($this->jobInstanceFactory, $this->eventDispatcher);
     $worker->setHostname($hostname);
     $process = new Process($pid);
     // @todo When worker is on another host, Process is over kill.
     $worker->setProcess($process);
     foreach ($queues as $queue) {
         $worker->addQueue($this->queueFactory->createQueue($queue));
         // @todo what about wildcard queues? :(
     }
     return $worker;
 }
 function it_constructs_workers_from_worker_ids(QueueFactoryInterface $queueFactory, QueueInterface $queueLow, QueueInterface $queueHigh)
 {
     $queueFactory->createQueue('high')->shouldBeCalled()->willReturn($queueHigh);
     $queueFactory->createQueue('low')->shouldBeCalled()->willReturn($queueLow);
     $this->createWorkerFromId('localhost:4753:high,low')->shouldReturnAnInstanceOf('Resque\\Component\\Worker\\Worker');
 }
Exemple #5
0
 /**
  * {@inheritDoc}
  */
 public function createQueue($name)
 {
     return $this->factory->createQueue($name);
 }
 function it_constructs_queue_names_in_to_queue_objects(QueueRegistryAdapterInterface $adapter, QueueFactoryInterface $factory, QueueInterface $queue)
 {
     $adapter->all()->willReturn(array('important-things'));
     $factory->createQueue('important-things')->willReturn($queue);
     $this->all()->shouldReturn(array('important-things' => $queue));
 }
Exemple #7
0
 function it_can_enqueue_a_job(QueueFactoryInterface $queueFactory, QueueInterface $queue)
 {
     $queueFactory->createQueue('foo')->willReturn($queue);
     $this->enqueue('foo', 'test')->shouldReturnAnInstanceOf('Resque\\Component\\Job\\Model\\JobInterface');
 }