influxdb connector WIP

This commit is contained in:
Alexander Zobnin
2018-10-28 21:03:56 +03:00
parent 612052ed33
commit a3ab102a06
3 changed files with 170 additions and 8 deletions

View File

@@ -1,8 +1,10 @@
import _ from 'lodash';
import * as utils from '../utils';
import responseHandler from '../responseHandler';
import DBConnector from './connectors/dbConnector';
import { ZabbixAPIConnector } from './connectors/zabbix_api/zabbixAPIConnector';
import { SQLConnector } from './connectors/sql/sqlConnector';
import { InfluxDBConnector } from './connectors/influxdb/influxdbConnector';
import { CachingProxy } from './proxy/cachingProxy';
import { ZabbixNotImplemented } from './connectors/dbConnector';
@@ -48,19 +50,27 @@ export class Zabbix {
this.zabbixAPI = new ZabbixAPIConnector(url, username, password, zabbixVersion, basicAuth, withCredentials, backendSrv);
this.proxyfyRequests();
this.cacheRequests();
this.bindRequests();
if (enableDirectDBConnection) {
let dbConnectorOptions = {
datasourceId: dbConnectionDatasourceId,
datasourceName: dbConnectionDatasourceName
};
this.dbConnector = new SQLConnector(dbConnectorOptions, backendSrv, datasourceSrv);
this.getHistoryDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getHistory, 'getHistory', this.dbConnector);
this.getTrendsDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getTrends, 'getTrends', this.dbConnector);
this.dbConnector = new DBConnector(dbConnectorOptions, backendSrv, datasourceSrv);
this.dbConnector.loadDBDataSource().then(ds => {
if (ds.type === 'influxdb') {
this.dbConnector = new InfluxDBConnector(dbConnectorOptions, backendSrv, datasourceSrv);
} else {
this.dbConnector = new SQLConnector(dbConnectorOptions, backendSrv, datasourceSrv);
}
}).then(() => {
this.getHistoryDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getHistory, 'getHistory', this.dbConnector);
this.getTrendsDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getTrends, 'getTrends', this.dbConnector);
});
}
this.proxyfyRequests();
this.cacheRequests();
this.bindRequests();
}
proxyfyRequests() {