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