public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $uri = $input->getArgument('uri'); $client = new EtcdClient($server); $data = $client->doRequest($uri); $output->writeln($data); }
public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $key = $input->getArgument('key'); $recursive = $input->getOption('recursive'); $client = new EtcdClient($server); $data = $client->ls($key, $recursive); $output->writeln($data); }
public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $key = $input->getArgument('key'); $output->writeln("<info>Removing key `{$key}`</info>"); $client = new EtcdClient($server); $data = $client->rm($key); $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo $json; }
public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $key = $input->getArgument('key'); $ttl = $input->getOption('ttl'); $output->writeln("<info>making directory `{$key}`</info>"); $client = new EtcdClient($server); $data = $client->mkdir($key, $ttl); $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo $json; }
public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $key = $input->getArgument('key'); $value = $input->getArgument('value'); $output->writeln("<info>Create `{$key}` with `{$value}`</info>"); $client = new EtcdClient($server); $data = $client->mk($key, $value); $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo $json; }
public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $key = $input->getArgument('key'); $value = $input->getArgument('value'); $ttl = $input->getOption('ttl'); echo "Setting `{$key}` to `{$value}`\n"; $client = new EtcdClient($server); $data = $client->set($key, $value, $ttl); $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo $json; }
public function execute(InputInterface $input, OutputInterface $output) { $server = $input->getArgument('server'); $key = $input->getArgument('key'); echo "Getting `{$key}` on `{$server}`\n"; $client = new EtcdClient($server); $data = $client->get($key); $output->writeln($data); /* $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo $json; */ }
public function testGetNode() { $key = 'node_key'; $setdata = $this->client->set($key, 'node_value'); $node = $this->client->getNode($key); $this->assertJsonStringEqualsJsonString(json_encode($node), json_encode($setdata['node'])); }
public function execute(InputInterface $input, OutputInterface $output) { $recursive = $input->getOption('recursive'); $server = $input->getArgument('server'); $key = $input->getArgument('key'); $afterIndex = $input->getOption('after-index'); $output->writeln("<info>Watching key `{$key}`</info>"); $client = new EtcdClient($server); $query = array('wait' => 'true'); if ($recursive) { $query['recursive'] = 'true'; } if ($afterIndex) { $query['waitIndex'] = $afterIndex; } $data = $client->get($key, $query); $output->writeln($data); }
* * The use case for this is a long running initial product download or sync * * We create a new lock with a 3 second time out * * We then try to immediately create a new lock, which should fail * * We then refresh the original lock, increasing the timeout by another 3 seconds * * We then try to create a new lock, which should fail */ $pid = getmypid(); $hostname = gethostname(); $jobPid = $hostname . ':' . $pid; echo "PID: {$jobPid}\n"; $client = new Client(); $client->setRoot("{$account_id}"); echo "Setting initial lock, timeout of 3 seconds\n"; $result1 = $client->set("/{$connector_id}", $jobPid, 3); print_r($result1); echo "\n"; echo "Printing directory tree\n"; print_r($client->listDir('/', true)); echo "\n"; echo "Attemping to set value\n"; $result2 = $client->set("/{$connector_id}", $jobPid . "-next", 3, ['prevExist' => 'false']); print_r($result2); echo "\n"; echo "Refreshing lock, timeout of 3 seconds\n"; $result1 = $client->set("/{$connector_id}", $jobPid, 3, ['prevValue' => $jobPid]); print_r($result1);