Authored by 郝肖肖

'flx'

const model = require('../../../lib/model');
const {DegradeServer} = require('../../models');
const zookeeperHelpers = require('../../zookeeper/zookeeper-helpers');
const _ = require('lodash');
class ZookeeperModel extends model {
constructor(ctx) {
... ... @@ -11,11 +12,9 @@ class ZookeeperModel extends model {
}
async setPath(path, val) {
let degradeServer = await DegradeServer.findAll();
let results = [];
(degradeServer || []).each(item => {
results.push(await zookeeperHelpers.creator(`${item.ip}:${item.port}`, path, val, true));
});
let results = await Promise.all(_.map(degradeServer, item => {
return zookeeperHelpers.creator(`${item.ip}:${item.port}`, path, val, true);
}));
return results && results[0] || false; // return Boolean
}
... ...