forked from alexguan/node-zookeeper-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.js
42 lines (35 loc) · 1022 Bytes
/
get.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Copyright (c) 2013 Yahoo! Inc. All rights reserved.
*
* Copyrights licensed under the MIT License. See the accompanying LICENSE file
* for terms.
*/
var zookeeper = require('../index.js');
var client = zookeeper.createClient(process.argv[2], { retries : 2 });
var path = process.argv[3];
function getData(client, path) {
client.getData(
path,
function (event) {
console.log('Got event: %s', event);
getData(client, path);
},
function (error, data, stat) {
if (error) {
console.log('Error occurred when getting data: %s.', error);
return;
}
console.log(
'Node: %s has data: %s, version: %d',
path,
data ? data.toString() : undefined,
stat.version
);
}
);
}
client.once('connected', function () {
console.log('Connected to ZooKeeper.');
getData(client, path);
});
client.connect();