Unistore: Reuse MySQL and Postgres Grafana core config instead of the object (#94223)
* Reuse MySQL and Postgres Grafana config instead of the object - Only reuse the Grafana DB object for SQLite. Support for SQLite will be added in a different PR - Fail when reusing the Grafana DB object if it is using DB instrumentation - In the case that we have to reuse a Grafana DB with its instrumentation, fail with an error that describes a workaround - Add regression tests to reproduce incident 2144 * remove temp file * fix linter * fix linter x2 * fix linter x3
This commit is contained in:
committed by
GitHub
parent
a82f102878
commit
7d32d5eff4
@@ -14,17 +14,35 @@ import (
|
||||
|
||||
var errInvalidUTF8Sequence = errors.New("invalid UTF-8 sequence")
|
||||
|
||||
type confGetter interface {
|
||||
Err() error
|
||||
Bool(key string) bool
|
||||
String(key string) string
|
||||
}
|
||||
|
||||
func newConfGetter(ds *setting.DynamicSection, keyPrefix string) confGetter {
|
||||
return §ionGetter{
|
||||
ds: ds,
|
||||
keyPrefix: keyPrefix,
|
||||
}
|
||||
}
|
||||
|
||||
type sectionGetter struct {
|
||||
*setting.DynamicSection
|
||||
err error
|
||||
ds *setting.DynamicSection
|
||||
keyPrefix string
|
||||
err error
|
||||
}
|
||||
|
||||
func (g *sectionGetter) Err() error {
|
||||
return g.err
|
||||
}
|
||||
|
||||
func (g *sectionGetter) Bool(key string) bool {
|
||||
return g.ds.Key(g.keyPrefix + key).MustBool(false)
|
||||
}
|
||||
|
||||
func (g *sectionGetter) String(key string) string {
|
||||
v := g.DynamicSection.Key(key).MustString("")
|
||||
v := g.ds.Key(g.keyPrefix + key).MustString("")
|
||||
if !utf8.ValidString(v) {
|
||||
g.err = fmt.Errorf("value for key %q: %w", key, errInvalidUTF8Sequence)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user