...
|
...
|
@@ -4,7 +4,7 @@ const redis = require('redis'); |
|
|
const bluebird = require('bluebird');
|
|
|
const config = require('../../config/common');
|
|
|
const logger = global.yoho.logger;
|
|
|
const mointor = global.yoho.mointorSender;
|
|
|
const monitor = global.yoho.monitorSender;
|
|
|
const timeout = 200; // redis 操作超时时间
|
|
|
let client;
|
|
|
|
...
|
...
|
@@ -14,11 +14,11 @@ try { |
|
|
bluebird.promisifyAll(redis.RedisClient.prototype);
|
|
|
bluebird.promisifyAll(redis.Multi.prototype);
|
|
|
|
|
|
const mointorType = _.get(mointor, 'type.REDIS');
|
|
|
const monitorType = _.get(monitor, 'type.REDIS');
|
|
|
|
|
|
client.all = args => {
|
|
|
if (!client.ready) {
|
|
|
mointor && mointor.tallyFail(mointorType);
|
|
|
monitor && monitor.tallyFail(monitorType);
|
|
|
if (Array.isArray(args)) {
|
|
|
return Promise.resolve(_.fill(args, false));
|
|
|
} else {
|
...
|
...
|
@@ -27,10 +27,10 @@ try { |
|
|
}
|
|
|
|
|
|
return client.multi.call(client, args).execAsync().timeout(timeout).then(res => {
|
|
|
mointor && mointor.tallySuccess(mointorType);
|
|
|
monitor && monitor.tallySuccess(monitorType);
|
|
|
return res;
|
|
|
}).catch((e)=>{
|
|
|
mointor && mointor.tallyFail(mointorType, e);
|
|
|
monitor && monitor.tallyFail(monitorType, e);
|
|
|
logger.error('redis exe time out');
|
|
|
return false;
|
|
|
});
|
...
|
...
|
|