Exemple #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!($serviceName = $input->getOption('service'))) {
         throw new \InvalidArgumentException("Specify a service name");
     }
     $suritcateServerUrl = $input->getArgument('suricate-server');
     $suricateClient = SuricateBuilder::build($suritcateServerUrl);
     $output->writeln(print_r($suricateClient->getAll($serviceName), true));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!($serviceName = $input->getOption('service'))) {
         throw new \InvalidArgumentException("Specify a service name");
     }
     if (!($nodeId = $input->getOption('id'))) {
         throw new \InvalidArgumentException("Specify a node id");
     }
     if (!($node = $input->getOption('node'))) {
         throw new \InvalidArgumentException("Specify a node");
     }
     if (!($total = $input->getOption('total'))) {
         throw new \InvalidArgumentException("Specify a number of heartbeats to send");
     }
     if (!($sleep = $input->getOption('wait'))) {
         throw new \InvalidArgumentException("Specify a wait time between heartbeats");
     }
     $suritcateServerUrl = $input->getArgument('suricate-server');
     $suricateClient = SuricateBuilder::build($suritcateServerUrl);
     $node = json_decode($node);
     while ($total) {
         $node->registrationTimeUTC = microtime(true) * 1000;
         if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
             $output->writeln("<comment>Sending a new Heartbeat. Pending </comment>{$total}");
             if (OutputInterface::VERBOSITY_VERY_VERBOSE <= $output->getVerbosity()) {
                 $output->writeln("Node to put: " . print_r($node, true));
             }
         }
         $success = $suricateClient->putService($serviceName, $nodeId, $node);
         if (!$success && OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
             $output->writeln("<error>Heartbeat failed!</error>");
         }
         $total -= $success;
         sleep($sleep);
     }
     $output->writeln("Done");
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $suritcateServerUrl = $input->getArgument('suricate-server');
     $suricateClient = SuricateBuilder::build($suritcateServerUrl);
     $output->writeln(print_r($suricateClient->getAllNames(), true));
 }
 protected function buildClient($serverUrl)
 {
     return SuricateBuilder::build($serverUrl);
 }