mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
RemoteCache: Refactor remote cache settings (#95672)
* refactor remote cache settings * fix cache error getting treating as application error * fix cache error getting treating as application error
This commit is contained in:
@@ -291,7 +291,7 @@ type Cfg struct {
|
||||
DataProxyUserAgent string
|
||||
|
||||
// DistributedCache
|
||||
RemoteCacheOptions *RemoteCacheOptions
|
||||
RemoteCacheOptions *RemoteCacheSettings
|
||||
|
||||
ViewersCanEdit bool
|
||||
EditorsCanAdmin bool
|
||||
@@ -1296,19 +1296,6 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
|
||||
enterprise := iniFile.Section("enterprise")
|
||||
cfg.EnterpriseLicensePath = valueAsString(enterprise, "license_path", filepath.Join(cfg.DataPath, "license.jwt"))
|
||||
|
||||
cacheServer := iniFile.Section("remote_cache")
|
||||
dbName := valueAsString(cacheServer, "type", "database")
|
||||
connStr := valueAsString(cacheServer, "connstr", "")
|
||||
prefix := valueAsString(cacheServer, "prefix", "")
|
||||
encryption := cacheServer.Key("encryption").MustBool(false)
|
||||
|
||||
cfg.RemoteCacheOptions = &RemoteCacheOptions{
|
||||
Name: dbName,
|
||||
ConnStr: connStr,
|
||||
Prefix: prefix,
|
||||
Encryption: encryption,
|
||||
}
|
||||
|
||||
geomapSection := iniFile.Section("geomap")
|
||||
basemapJSON := valueAsString(geomapSection, "default_baselayer_config", "")
|
||||
if basemapJSON != "" {
|
||||
@@ -1322,6 +1309,7 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
|
||||
}
|
||||
cfg.GeomapEnableCustomBaseLayers = geomapSection.Key("enable_custom_baselayers").MustBool(true)
|
||||
|
||||
cfg.readRemoteCacheSettings()
|
||||
cfg.readDateFormats()
|
||||
cfg.readGrafanaJavascriptAgentConfig()
|
||||
|
||||
@@ -1354,13 +1342,6 @@ func valueAsString(section *ini.Section, keyName string, defaultValue string) st
|
||||
return section.Key(keyName).MustString(defaultValue)
|
||||
}
|
||||
|
||||
type RemoteCacheOptions struct {
|
||||
Name string
|
||||
ConnStr string
|
||||
Prefix string
|
||||
Encryption bool
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readSAMLConfig() {
|
||||
samlSec := cfg.Raw.Section("auth.saml")
|
||||
cfg.SAMLAuthEnabled = samlSec.Key("enabled").MustBool(false)
|
||||
|
||||
23
pkg/setting/setting_remote_cache.go
Normal file
23
pkg/setting/setting_remote_cache.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package setting
|
||||
|
||||
type RemoteCacheSettings struct {
|
||||
Name string
|
||||
ConnStr string
|
||||
Prefix string
|
||||
Encryption bool
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readRemoteCacheSettings() {
|
||||
cacheServer := cfg.Raw.Section("remote_cache")
|
||||
dbName := valueAsString(cacheServer, "type", "database")
|
||||
connStr := valueAsString(cacheServer, "connstr", "")
|
||||
prefix := valueAsString(cacheServer, "prefix", "")
|
||||
encryption := cacheServer.Key("encryption").MustBool(false)
|
||||
|
||||
cfg.RemoteCacheOptions = &RemoteCacheSettings{
|
||||
Name: dbName,
|
||||
ConnStr: connStr,
|
||||
Prefix: prefix,
|
||||
Encryption: encryption,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user