Merge branch 'cache-service' into grafana-3.0
This commit is contained in:
@@ -35,11 +35,15 @@ function (angular, _, dateMath, utils, metricFunctions) {
|
|||||||
this.trends = instanceSettings.jsonData.trends;
|
this.trends = instanceSettings.jsonData.trends;
|
||||||
this.trendsFrom = instanceSettings.jsonData.trendsFrom || '7d';
|
this.trendsFrom = instanceSettings.jsonData.trendsFrom || '7d';
|
||||||
|
|
||||||
|
// Set cache update interval
|
||||||
|
var ttl = instanceSettings.jsonData.cacheTTL || '1h';
|
||||||
|
this.cacheTTL = utils.parseInterval(ttl);
|
||||||
|
|
||||||
// Initialize Zabbix API
|
// Initialize Zabbix API
|
||||||
this.zabbixAPI = new ZabbixAPI(this.url, this.username, this.password, this.basicAuth, this.withCredentials);
|
this.zabbixAPI = new ZabbixAPI(this.url, this.username, this.password, this.basicAuth, this.withCredentials);
|
||||||
|
|
||||||
// Initialize cache service
|
// Initialize cache service
|
||||||
this.zabbixCache = new ZabbixCachingProxy(this.zabbixAPI);
|
this.zabbixCache = new ZabbixCachingProxy(this.zabbixAPI, this.cacheTTL);
|
||||||
|
|
||||||
// Initialize query builder
|
// Initialize query builder
|
||||||
this.queryProcessor = new QueryProcessor(this.zabbixCache);
|
this.queryProcessor = new QueryProcessor(this.zabbixCache);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
ng-model='current.jsonData.username'
|
ng-model='current.jsonData.username'
|
||||||
placeholder="">
|
placeholder="">
|
||||||
</li>
|
</li>
|
||||||
<li class="tight-form-item">
|
<li class="tight-form-item" style="width: 80px">
|
||||||
Password
|
Password
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -25,6 +25,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="tight-form last">
|
<div class="tight-form last">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
|
<li class="tight-form-item" style="width: 200px">
|
||||||
|
Cache update interval
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<input type="text" class="tight-form-input input-small"
|
||||||
|
ng-model='current.jsonData.cacheTTL'
|
||||||
|
placeholder="1h">
|
||||||
|
</li>
|
||||||
<li class="tight-form-item" style="width: 80px">
|
<li class="tight-form-item" style="width: 80px">
|
||||||
Trends
|
Trends
|
||||||
<input class="cr1" id="current.jsonData.trends" type="checkbox"
|
<input class="cr1" id="current.jsonData.trends" type="checkbox"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function (angular, _, utils) {
|
|||||||
|
|
||||||
// Use factory() instead service() for multiple datasources support.
|
// Use factory() instead service() for multiple datasources support.
|
||||||
// Each datasource instance must initialize its own cache.
|
// Each datasource instance must initialize its own cache.
|
||||||
module.factory('ZabbixCachingProxy', function($q) {
|
module.factory('ZabbixCachingProxy', function($q, $interval) {
|
||||||
|
|
||||||
function ZabbixCachingProxy(zabbixAPI, ttl) {
|
function ZabbixCachingProxy(zabbixAPI, ttl) {
|
||||||
this.zabbixAPI = zabbixAPI;
|
this.zabbixAPI = zabbixAPI;
|
||||||
@@ -33,6 +33,9 @@ function (angular, _, utils) {
|
|||||||
|
|
||||||
// Wrap _refresh() method to call it once.
|
// Wrap _refresh() method to call it once.
|
||||||
this.refresh = callOnce(p._refresh, this.refreshPromise);
|
this.refresh = callOnce(p._refresh, this.refreshPromise);
|
||||||
|
|
||||||
|
// Update cache periodically
|
||||||
|
$interval(_.bind(this.refresh, this), this.ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = ZabbixCachingProxy.prototype;
|
var p = ZabbixCachingProxy.prototype;
|
||||||
|
|||||||
Reference in New Issue
Block a user