From cc64d65c2f13fa28cea03c47630e07415f7ea0b5 Mon Sep 17 00:00:00 2001 From: stuart nelson Date: Thu, 9 Jun 2016 12:57:55 +0200 Subject: [PATCH] Rename cacheKey to exprID/requestID Depending on context in the code, rename cacheKey to exprID when it identifies a unique expression, and rename cacheKey to requestID when it is identifying a request. --- public/app/core/services/backend_srv.js | 10 +++++----- public/app/features/panel/metrics_panel_ctrl.ts | 2 +- public/app/plugins/datasource/prometheus/datasource.ts | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/public/app/core/services/backend_srv.js b/public/app/core/services/backend_srv.js index 71e4b50d51e..5ba40dfc86b 100644 --- a/public/app/core/services/backend_srv.js +++ b/public/app/core/services/backend_srv.js @@ -96,18 +96,18 @@ function (angular, _, coreModule, config) { this.datasourceRequest = function(options) { options.retry = options.retry || 0; - // A cacheKey is provided by the datasource as a unique identifier for a - // particular query. If the cacheKey exists, the promise it is keyed to + // A requestID is provided by the datasource as a unique identifier for a + // particular query. If the requestID exists, the promise it is keyed to // is canceled, canceling the previous datasource request if it is still // in-flight. var canceler; - if (options.cacheKey) { - if (canceler = datasourceInFlightRequests[options.cacheKey]) { + if (options.requestID) { + if (canceler = datasourceInFlightRequests[options.requestID]) { canceler.resolve(); } canceler = $q.defer(); options.timeout = canceler.promise; - datasourceInFlightRequests[options.cacheKey] = canceler; + datasourceInFlightRequests[options.requestID] = canceler; } var requestIsLocal = options.url.indexOf('/') === 0; diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index e20df095d22..2a72ef4b24e 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -183,7 +183,7 @@ class MetricsPanelCtrl extends PanelCtrl { }; metricsQuery.targets.forEach(function(target) { - target.cacheKey = target.expr + target.refId + metricsQuery.panelId; + target.exprID = target.expr + target.refId + metricsQuery.panelId; }); return datasource.query(metricsQuery); diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index 0e65ba6fb22..3548b4fedb2 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -21,11 +21,11 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS this.withCredentials = instanceSettings.withCredentials; this.lastErrors = {}; - this._request = function(method, url, cacheKey) { + this._request = function(method, url, requestID) { var options: any = { url: this.url + url, method: method, - cacheKey: cacheKey, + requestID: requestID, }; if (this.basicAuth || this.withCredentials) { @@ -77,7 +77,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS var query: any = {}; query.expr = templateSrv.replace(target.expr, options.scopedVars, self.interpolateQueryExpr); - query.cacheKey = target.cacheKey; + query.requestID = target.exprID; var interval = target.interval || options.interval; var intervalFactor = target.intervalFactor || 1; @@ -128,7 +128,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS this.performTimeSeriesQuery = function(query, start, end) { var url = '/api/v1/query_range?query=' + encodeURIComponent(query.expr) + '&start=' + start + '&end=' + end + '&step=' + query.step; - return this._request('GET', url, query.cacheKey); + return this._request('GET', url, query.requestID); }; this.performSuggestQuery = function(query) {