mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user