LinkORB\Component\Etcd\Client::getNode PHP 메소드

getNode() 공개 메소드

Retrieve the value of a key
public getNode ( string $key, array $flags = null ) : array
$key string
$flags array the extra query params
리턴 array
    public function getNode($key, array $flags = null)
    {
        $query = array();
        if ($flags) {
            $query = array('query' => $flags);
        }
        $request = $this->guzzleclient->get($this->buildKeyUri($key), null, $query);
        $response = $request->send();
        $body = $response->json();
        if (isset($body['errorCode'])) {
            throw new KeyNotFoundException($body['message'], $body['errorCode']);
        }
        return $body['node'];
    }

Usage Example

예제 #1
0
 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']));
 }