public function testWatchOnly() { $action = 'test1'; $this->pheanstalk->expects($this->once())->method('listTubesWatched')->will($this->returnValue(['test'])); $this->pheanstalk->expects($this->once())->method('ignore')->with('test'); $this->pheanstalk->expects($this->once())->method('watch')->with($action); $this->manager->watchOnly($action); }
/** * @param OutputInterface $output * @param string $action * @param int $limit */ protected function inspect(OutputInterface $output, $action, $limit = null) { $output->writeln(sprintf('Inspecting jobs for the <info>%s</info> action', $action)); $this->manager->watchOnly([$action]); $jobs = []; while ($job = $this->manager->get(1)) { $output->writeln(sprintf('<info>%d</info>: <comment>%s</comment>', $job->getId(), $job->getData())); $jobs[] = $job; if (null !== $limit && sizeof($jobs) >= $limit) { break; } } $output->writeln('Releasing the jobs back to the queue, <error>don\'t cancel this action!</error>'); foreach ($jobs as $job) { $stats = $this->manager->getJobStats($job); $this->manager->getPheanstalk()->release($job, $stats['pri']); } }
/** * @param string[] $include * @param string[] $exclude */ protected function watchActions(array $include = [], array $exclude = []) { $actions = array_keys($this->manager->getExecutors()); if (empty($include)) { $include = $actions; } if (!empty($diff = array_diff($include, $actions))) { throw new \InvalidArgumentException(sprintf('Action(s) "%s" are not defined by QueueManager', implode(', ', $diff))); } if (!empty($diff = array_diff($exclude, $actions))) { throw new \InvalidArgumentException(sprintf('Filter(s) "%s" are not defined by QueueManager', implode(', ', $diff))); } $include = array_diff($include, $exclude); if (empty($include)) { throw new \InvalidArgumentException('No actions specified to run'); } // watch only these actions $this->manager->watchOnly($include); }