mirror of https://github.com/grafana/grafana.git
move caching config to the right place in the ds info
This commit is contained in:
parent
80076ff7f7
commit
395c74b585
|
@ -133,6 +133,7 @@ export interface DataSourcePluginMeta<T extends KeyValue = {}> extends PluginMet
|
||||||
hasQueryHelp?: boolean;
|
hasQueryHelp?: boolean;
|
||||||
category?: string;
|
category?: string;
|
||||||
queryOptions?: PluginMetaQueryOptions;
|
queryOptions?: PluginMetaQueryOptions;
|
||||||
|
cachingConfig?: PluginQueryCachingConfig;
|
||||||
sort?: number;
|
sort?: number;
|
||||||
streaming?: boolean;
|
streaming?: boolean;
|
||||||
unlicensed?: boolean;
|
unlicensed?: boolean;
|
||||||
|
@ -145,6 +146,10 @@ interface PluginMetaQueryOptions {
|
||||||
maxDataPoints?: boolean;
|
maxDataPoints?: boolean;
|
||||||
minInterval?: boolean;
|
minInterval?: boolean;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Information about the datasource's query caching configuration
|
||||||
|
* When the caching feature is disabled, this config will always be falsy
|
||||||
|
*/
|
||||||
interface PluginQueryCachingConfig {
|
interface PluginQueryCachingConfig {
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
TTLMs?: number;
|
TTLMs?: number;
|
||||||
|
@ -229,7 +234,6 @@ abstract class DataSourceApi<
|
||||||
this.id = instanceSettings.id;
|
this.id = instanceSettings.id;
|
||||||
this.type = instanceSettings.type;
|
this.type = instanceSettings.type;
|
||||||
this.meta = instanceSettings.meta;
|
this.meta = instanceSettings.meta;
|
||||||
this.cachingConfig = instanceSettings.cachingConfig;
|
|
||||||
this.uid = instanceSettings.uid;
|
this.uid = instanceSettings.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,12 +311,6 @@ abstract class DataSourceApi<
|
||||||
*/
|
*/
|
||||||
meta: DataSourcePluginMeta;
|
meta: DataSourcePluginMeta;
|
||||||
|
|
||||||
/**
|
|
||||||
* Information about the datasource's query caching configuration
|
|
||||||
* When the caching feature is disabled, this config will always be empty
|
|
||||||
*/
|
|
||||||
cachingConfig?: PluginQueryCachingConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by alerting to check if query contains template variables
|
* Used by alerting to check if query contains template variables
|
||||||
*/
|
*/
|
||||||
|
@ -599,7 +597,6 @@ export interface DataSourceInstanceSettings<T extends DataSourceJsonData = DataS
|
||||||
type: string;
|
type: string;
|
||||||
name: string;
|
name: string;
|
||||||
meta: DataSourcePluginMeta;
|
meta: DataSourcePluginMeta;
|
||||||
cachingConfig?: PluginQueryCachingConfig;
|
|
||||||
readOnly: boolean;
|
readOnly: boolean;
|
||||||
url?: string;
|
url?: string;
|
||||||
jsonData: T;
|
jsonData: T;
|
||||||
|
|
|
@ -358,7 +358,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, enabledPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg, ok := cacheCfgs[dsDTO.UID]; ok {
|
if cfg, ok := cacheCfgs[dsDTO.UID]; ok {
|
||||||
dsDTO.EnterpriseCachingConfig = cfg
|
dsDTO.PluginMeta.EnterpriseCachingConfig = cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSources[ds.Name] = dsDTO
|
dataSources[ds.Name] = dsDTO
|
||||||
|
@ -385,7 +385,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, enabledPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg, ok := cacheCfgs[dto.UID]; ok {
|
if cfg, ok := cacheCfgs[dto.UID]; ok {
|
||||||
dto.EnterpriseCachingConfig = cfg
|
dto.PluginMeta.EnterpriseCachingConfig = cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSources[ds.Name] = dto
|
dataSources[ds.Name] = dto
|
||||||
|
|
|
@ -208,6 +208,8 @@ type PluginMetaDTO struct {
|
||||||
|
|
||||||
Module string `json:"module"`
|
Module string `json:"module"`
|
||||||
BaseURL string `json:"baseUrl"`
|
BaseURL string `json:"baseUrl"`
|
||||||
|
|
||||||
|
EnterpriseCachingConfig querycaching.CacheConfig `json:"cachingConfig,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataSourceDTO struct {
|
type DataSourceDTO struct {
|
||||||
|
@ -227,8 +229,6 @@ type DataSourceDTO struct {
|
||||||
BasicAuth string `json:"basicAuth,omitempty"`
|
BasicAuth string `json:"basicAuth,omitempty"`
|
||||||
WithCredentials bool `json:"withCredentials,omitempty"`
|
WithCredentials bool `json:"withCredentials,omitempty"`
|
||||||
|
|
||||||
EnterpriseCachingConfig querycaching.CacheConfig `json:"cachingConfig,omitempty"`
|
|
||||||
|
|
||||||
// InfluxDB
|
// InfluxDB
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class PanelEditorQueries extends PureComponent<Props> {
|
||||||
type: datasourceSettings?.type,
|
type: datasourceSettings?.type,
|
||||||
uid: datasourceSettings?.uid,
|
uid: datasourceSettings?.uid,
|
||||||
},
|
},
|
||||||
queryCachingTTL: datasourceSettings?.cachingConfig?.enabled ? panel.queryCachingTTL : undefined,
|
queryCachingTTL: datasourceSettings?.meta.cachingConfig?.enabled ? panel.queryCachingTTL : undefined,
|
||||||
queries: panel.targets,
|
queries: panel.targets,
|
||||||
maxDataPoints: panel.maxDataPoints,
|
maxDataPoints: panel.maxDataPoints,
|
||||||
minInterval: panel.interval,
|
minInterval: panel.interval,
|
||||||
|
|
|
@ -188,7 +188,7 @@ export class QueryGroupOptionsEditor extends PureComponent<Props, State> {
|
||||||
|
|
||||||
const tooltip = `Cache time-to-live: How long results from this queries in this panel will be cached, in milliseconds. Defaults to the TTL in the caching configuration for this datasource.`;
|
const tooltip = `Cache time-to-live: How long results from this queries in this panel will be cached, in milliseconds. Defaults to the TTL in the caching configuration for this datasource.`;
|
||||||
|
|
||||||
if (!dataSource.cachingConfig?.enabled) {
|
if (!dataSource.meta.cachingConfig?.enabled) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ export class QueryGroupOptionsEditor extends PureComponent<Props, State> {
|
||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
className="width-6"
|
className="width-6"
|
||||||
placeholder={`${dataSource.cachingConfig.TTLMs}`}
|
placeholder={`${dataSource.meta.cachingConfig.TTLMs}`}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
onBlur={this.onQueryCachingTTLBlur}
|
onBlur={this.onQueryCachingTTLBlur}
|
||||||
defaultValue={options.queryCachingTTL ?? undefined}
|
defaultValue={options.queryCachingTTL ?? undefined}
|
||||||
|
|
Loading…
Reference in New Issue