Refactor: move zabbix api response handle to separate module.

This commit is contained in:
Alexander Zobnin
2016-11-12 21:26:34 +03:00
parent 2e57b9b166
commit 88ddcd0c42
3 changed files with 114 additions and 106 deletions

View File

@@ -5,6 +5,7 @@ import * as utils from './utils';
import * as migrations from './migrations';
import * as metricFunctions from './metricFunctions';
import DataProcessor from './DataProcessor';
import responseHandler from './responseHandler';
import './zabbixAPI.service.js';
import './zabbixCache.service.js';
import './queryProcessor.service.js';
@@ -120,11 +121,10 @@ class ZabbixAPIDatasource {
}
return this.zabbixAPI
.getSLA(target.itservice.serviceid, timeFrom, timeTo)
.then(slaObject => {
return this.queryProcessor
.handleSLAResponse(target.itservice, target.slaProperty, slaObject);
});
.getSLA(target.itservice.serviceid, timeFrom, timeTo)
.then(slaObject => {
return responseHandler.handleSLAResponse(target.itservice, target.slaProperty, slaObject);
});
}
});
@@ -168,7 +168,7 @@ class ZabbixAPIDatasource {
getHistory = this.zabbixAPI
.getTrend(items, timeFrom, timeTo)
.then(history => {
return this.queryProcessor.handleTrends(history, items, addHostName, valueType);
return responseHandler.handleTrends(history, items, addHostName, valueType);
});
}
@@ -177,7 +177,7 @@ class ZabbixAPIDatasource {
getHistory = this.zabbixCache
.getHistory(items, timeFrom, timeTo)
.then(history => {
return this.queryProcessor.handleHistory(history, items, addHostName);
return responseHandler.handleHistory(history, items, addHostName);
});
}
@@ -233,7 +233,7 @@ class ZabbixAPIDatasource {
if (items.length) {
return this.zabbixAPI.getHistory(items, timeFrom, timeTo)
.then(history => {
return this.queryProcessor.convertHistory(history, items, false, (point) => {
return responseHandler.convertHistory(history, items, false, (point) => {
let value = point.value;
// Regex-based extractor