...
|
...
|
@@ -2,7 +2,6 @@ const mysql = require('mysql'); |
|
|
const _ = require('lodash');
|
|
|
const md5 = require('yoho-md5');
|
|
|
const qs = require('querystring');
|
|
|
const monitorType = 'sql';
|
|
|
|
|
|
class SqlHelper {
|
|
|
constructor(database) {
|
...
|
...
|
@@ -10,6 +9,7 @@ class SqlHelper { |
|
|
this.logger = global.yoho.logger;
|
|
|
this.cache = global.yoho.cache;
|
|
|
this.monitor = global.yoho.monitorSender;
|
|
|
this.monitorType = _.get(this.monitor, 'type.SQL');
|
|
|
database = database || 'mysql';
|
|
|
this.createPool(database);
|
|
|
}
|
...
|
...
|
@@ -97,12 +97,12 @@ class SqlHelper { |
|
|
// 写入缓存
|
|
|
cacheTime && this.cache.set(cacheKey, result, cacheTime);
|
|
|
resolve(result);
|
|
|
this.monitor && this.monitor.tallySuccess(monitorType);
|
|
|
this.monitor && this.monitor.tallySuccess(this.monitorType);
|
|
|
}
|
|
|
});
|
|
|
}).catch(e => {
|
|
|
reject(e);
|
|
|
this.monitor && this.monitor.tallyFail(monitorType, e);
|
|
|
this.monitor && this.monitor.tallyFail(this.monitorType, e);
|
|
|
});
|
|
|
});
|
|
|
}
|
...
|
...
|
|