Пример #1
0
 /**
  * @return array
  */
 public function all()
 {
     $tubes = $this->connection->listTubes();
     foreach ($tubes as $index => $tube) {
         $tubes[$index] = $this->find($tube);
     }
     return $tubes;
 }
Пример #2
0
 /** {@inheritdoc} */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $srcHost = $input->getArgument(self::ATTR_SRC_HOST);
     $dstHost = $input->getArgument(self::ATTR_DST_HOST);
     $srcPort = $input->getOption(self::OPT_SRC_PORT);
     $dstPort = $input->getOption(self::OPT_DST_PORT);
     $src = new Pheanstalk($srcHost, $srcPort);
     $dst = new Pheanstalk($dstHost, $dstPort);
     foreach ($src->listTubes() as $tube) {
         var_dump($tube);
     }
 }
Пример #3
0
 private function generateStatsTable(Pheanstalk $pheanstalk, $tube = null)
 {
     if ($tube) {
         $tubes[] = $tube;
     } else {
         $tubes = $pheanstalk->listTubes();
     }
     $stats = array();
     foreach ($tubes as $tube) {
         $stats[$tube] = (array) $pheanstalk->statsTube($tube);
     }
     $statsToDisplay = array('current-jobs-urgent', 'current-jobs-ready', 'current-jobs-reserved', 'current-jobs-delayed', 'current-jobs-buried', 'current-waiting', 'total-jobs');
     foreach ($stats as &$tubeStats) {
         foreach ($tubeStats as $key => $val) {
             if (!in_array($key, $statsToDisplay)) {
                 unset($tubeStats[$key]);
             }
         }
     }
     return $stats;
 }
Пример #4
0
 /** {@inheritdoc} */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $srcHost = $input->getArgument(self::ATTR_HOST);
     $srcPort = $input->getOption(self::OPT_PORT);
     $sort = $input->getOption(self::OPT_SORT);
     $order = $input->getOption(self::OPT_ORDER);
     $noZeros = $input->getOption(self::OPT_NO_ZEROS);
     $columns = ['name' => 'name', 'current-jobs-ready' => 'ready', 'current-jobs-reserved' => 'reserved', 'current-jobs-delayed' => 'delayed', 'current-jobs-buried' => 'buried'];
     $src = new Pheanstalk($srcHost, $srcPort);
     $table = new TableHelper(false);
     $table->setLayout(TableHelper::LAYOUT_BORDERLESS);
     $table->setHeaders($columns);
     $tubeNames = $src->listTubes();
     ksort($tubeNames);
     $data = [];
     foreach ($tubeNames as $tube) {
         /** @var ArrayResponse $response */
         $response = $src->statsTube($tube);
         $tubeData = $response->getArrayCopy();
         $tubeData = array_intersect_key($tubeData, $columns);
         if ($noZeros) {
             foreach ($tubeData as $key => $value) {
                 if ('0' === $value) {
                     $tubeData[$key] = '';
                 }
             }
         }
         $data[] = $tubeData;
     }
     $column = array_search($sort, $columns);
     uasort($data, function (array $a1, array $a2) use($column, $order) {
         return strnatcmp($a1[$column], $a2[$column]) * $order;
     });
     $table->addRows($data);
     $table->render($output);
 }
Пример #5
0
 /**
  * Return a list of queues/tubes on the queueing server
  *
  * @return array Array of Queues
  */
 public function getQueues()
 {
     return $this->queue->listTubes();
 }