setter.js
667 Bytes
'usu strict';
const _ = require('lodash');
const zookeeper = require('node-zookeeper-client');
module.exports = (server, path, val) => new Promise((resolve, reject) => {
const client = zookeeper.createClient(server);
client.once('connected', function () {
client.setData(path, new Buffer(val.toString()), function(err, data, stat) {
if (err) {
console.log('update path %s data error');
resolve();
} else {
console.log('path %s data change to', path, val);
resolve(true);
}
client.close();
});
});
client.connect();
});