...
|
...
|
@@ -11,28 +11,37 @@ class ZookeeperModel extends model { |
|
|
return await DegradeServer.findAll();
|
|
|
}
|
|
|
async setPath(path, val) {
|
|
|
let degradeServer = await this.getConfigAll();
|
|
|
let results = await Promise.all(_.map(degradeServer, item => {
|
|
|
return zookeeperHelpers.creator(`${item.ip}:${item.port}`, path, val, true);
|
|
|
}));
|
|
|
let degradeServer = await DegradeServer.findOne({
|
|
|
type: 'qcloud'
|
|
|
});
|
|
|
|
|
|
return results && results[0] || false; // return Boolean
|
|
|
if (_.isEmpty(degradeServer)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return zookeeperHelpers.creator(`${degradeServer.ip}:${degradeServer.port}`, path, val, true); // return Boolean
|
|
|
}
|
|
|
async getPath(path) {
|
|
|
let degradeServer = await this.getConfigAll();
|
|
|
let degradeServer = await DegradeServer.findOne({
|
|
|
type: 'qcloud'
|
|
|
});
|
|
|
|
|
|
if (degradeServer[0]) {
|
|
|
return await zookeeperHelpers.getter(`${degradeServer[0].ip}:${degradeServer[0].port}`, path);
|
|
|
if (_.isEmpty(degradeServer)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
return await zookeeperHelpers.getter(`${degradeServer.ip}:${degradeServer.port}`, path);
|
|
|
}
|
|
|
async removePath(path) {
|
|
|
let degradeServer = await this.getConfigAll();
|
|
|
let degradeServer = await DegradeServer.findOne({
|
|
|
type: 'qcloud'
|
|
|
});
|
|
|
|
|
|
if (degradeServer[0]) {
|
|
|
return await zookeeperHelpers.remove(`${degradeServer[0].ip}:${degradeServer[0].port}`, path);
|
|
|
if (_.isEmpty(degradeServer)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return await zookeeperHelpers.remove(`${degradeServer.ip}:${degradeServer.port}`, path);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|