Authored by 毕凯

Merge branch 'feature/risk' into 'master'

'flx'



See merge request !29
@@ -11,28 +11,37 @@ class ZookeeperModel extends model { @@ -11,28 +11,37 @@ class ZookeeperModel extends model {
11 return await DegradeServer.findAll(); 11 return await DegradeServer.findAll();
12 } 12 }
13 async setPath(path, val) { 13 async setPath(path, val) {
14 - let degradeServer = await this.getConfigAll();  
15 - let results = await Promise.all(_.map(degradeServer, item => {  
16 - return zookeeperHelpers.creator(`${item.ip}:${item.port}`, path, val, true);  
17 - })); 14 + let degradeServer = await DegradeServer.findOne({
  15 + type: 'qcloud'
  16 + });
18 17
19 - return results && results[0] || false; // return Boolean 18 + if (_.isEmpty(degradeServer)) {
  19 + return false;
  20 + }
  21 +
  22 + return zookeeperHelpers.creator(`${degradeServer.ip}:${degradeServer.port}`, path, val, true); // return Boolean
20 } 23 }
21 async getPath(path) { 24 async getPath(path) {
22 - let degradeServer = await this.getConfigAll(); 25 + let degradeServer = await DegradeServer.findOne({
  26 + type: 'qcloud'
  27 + });
23 28
24 - if (degradeServer[0]) {  
25 - return await zookeeperHelpers.getter(`${degradeServer[0].ip}:${degradeServer[0].port}`, path); 29 + if (_.isEmpty(degradeServer)) {
  30 + return false;
26 } 31 }
27 32
28 - return null; 33 + return await zookeeperHelpers.getter(`${degradeServer.ip}:${degradeServer.port}`, path);
29 } 34 }
30 async removePath(path) { 35 async removePath(path) {
31 - let degradeServer = await this.getConfigAll(); 36 + let degradeServer = await DegradeServer.findOne({
  37 + type: 'qcloud'
  38 + });
32 39
33 - if (degradeServer[0]) {  
34 - return await zookeeperHelpers.remove(`${degradeServer[0].ip}:${degradeServer[0].port}`, path); 40 + if (_.isEmpty(degradeServer)) {
  41 + return false;
35 } 42 }
  43 +
  44 + return await zookeeperHelpers.remove(`${degradeServer.ip}:${degradeServer.port}`, path);
36 } 45 }
37 } 46 }
38 47