mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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;
|
||||
category?: string;
|
||||
queryOptions?: PluginMetaQueryOptions;
|
||||
cachingConfig?: PluginQueryCachingConfig;
|
||||
sort?: number;
|
||||
streaming?: boolean;
|
||||
unlicensed?: boolean;
|
||||
@ -145,6 +146,10 @@ interface PluginMetaQueryOptions {
|
||||
maxDataPoints?: 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 {
|
||||
enabled?: boolean;
|
||||
TTLMs?: number;
|
||||
@ -229,7 +234,6 @@ abstract class DataSourceApi<
|
||||
this.id = instanceSettings.id;
|
||||
this.type = instanceSettings.type;
|
||||
this.meta = instanceSettings.meta;
|
||||
this.cachingConfig = instanceSettings.cachingConfig;
|
||||
this.uid = instanceSettings.uid;
|
||||
}
|
||||
|
||||
@ -307,12 +311,6 @@ abstract class DataSourceApi<
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -599,7 +597,6 @@ export interface DataSourceInstanceSettings<T extends DataSourceJsonData = DataS
|
||||
type: string;
|
||||
name: string;
|
||||
meta: DataSourcePluginMeta;
|
||||
cachingConfig?: PluginQueryCachingConfig;
|
||||
readOnly: boolean;
|
||||
url?: string;
|
||||
jsonData: T;
|
||||
|
@ -358,7 +358,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, enabledPlugin
|
||||
}
|
||||
|
||||
if cfg, ok := cacheCfgs[dsDTO.UID]; ok {
|
||||
dsDTO.EnterpriseCachingConfig = cfg
|
||||
dsDTO.PluginMeta.EnterpriseCachingConfig = cfg
|
||||
}
|
||||
|
||||
dataSources[ds.Name] = dsDTO
|
||||
@ -385,7 +385,7 @@ func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, enabledPlugin
|
||||
}
|
||||
|
||||
if cfg, ok := cacheCfgs[dto.UID]; ok {
|
||||
dto.EnterpriseCachingConfig = cfg
|
||||
dto.PluginMeta.EnterpriseCachingConfig = cfg
|
||||
}
|
||||
|
||||
dataSources[ds.Name] = dto
|
||||
|
@ -208,6 +208,8 @@ type PluginMetaDTO struct {
|
||||
|
||||
Module string `json:"module"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
|
||||
EnterpriseCachingConfig querycaching.CacheConfig `json:"cachingConfig,omitempty"`
|
||||
}
|
||||
|
||||
type DataSourceDTO struct {
|
||||
@ -227,8 +229,6 @@ type DataSourceDTO struct {
|
||||
BasicAuth string `json:"basicAuth,omitempty"`
|
||||
WithCredentials bool `json:"withCredentials,omitempty"`
|
||||
|
||||
EnterpriseCachingConfig querycaching.CacheConfig `json:"cachingConfig,omitempty"`
|
||||
|
||||
// InfluxDB
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
|
@ -33,7 +33,7 @@ export class PanelEditorQueries extends PureComponent<Props> {
|
||||
type: datasourceSettings?.type,
|
||||
uid: datasourceSettings?.uid,
|
||||
},
|
||||
queryCachingTTL: datasourceSettings?.cachingConfig?.enabled ? panel.queryCachingTTL : undefined,
|
||||
queryCachingTTL: datasourceSettings?.meta.cachingConfig?.enabled ? panel.queryCachingTTL : undefined,
|
||||
queries: panel.targets,
|
||||
maxDataPoints: panel.maxDataPoints,
|
||||
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.`;
|
||||
|
||||
if (!dataSource.cachingConfig?.enabled) {
|
||||
if (!dataSource.meta.cachingConfig?.enabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ export class QueryGroupOptionsEditor extends PureComponent<Props, State> {
|
||||
<Input
|
||||
type="number"
|
||||
className="width-6"
|
||||
placeholder={`${dataSource.cachingConfig.TTLMs}`}
|
||||
placeholder={`${dataSource.meta.cachingConfig.TTLMs}`}
|
||||
spellCheck={false}
|
||||
onBlur={this.onQueryCachingTTLBlur}
|
||||
defaultValue={options.queryCachingTTL ?? undefined}
|
||||
|
Loading…
Reference in New Issue
Block a user