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) { $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; }
* 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); echo "\n"; // get key value echo "Checking if key has expired\n";