mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 23:37:01 -06:00
606a74d0af
* Zanana: Initial work to run zanana as ebeddedn or standalone * Add addr settings for when remote client is used. * sync dependencies * Lock mysql driver version --------- Co-authored-by: Dan Cech <dcech@grafana.com>
38 lines
767 B
Go
38 lines
767 B
Go
package setting
|
|
|
|
import (
|
|
"slices"
|
|
)
|
|
|
|
type ZanzanaMode string
|
|
|
|
const (
|
|
ZanzanaModeClient ZanzanaMode = "client"
|
|
ZanzanaModeEmbedded ZanzanaMode = "embedded"
|
|
)
|
|
|
|
type ZanzanaSettings struct {
|
|
// Addr is only used when mode is set to client
|
|
Addr string
|
|
// Mode can either be embedded or client
|
|
Mode ZanzanaMode
|
|
}
|
|
|
|
func (cfg *Cfg) readZanzanaSettings() {
|
|
s := ZanzanaSettings{}
|
|
|
|
sec := cfg.Raw.Section("zanzana")
|
|
s.Mode = ZanzanaMode(sec.Key("mode").MustString("embedded"))
|
|
|
|
validModes := []ZanzanaMode{ZanzanaModeEmbedded, ZanzanaModeClient}
|
|
|
|
if !slices.Contains(validModes, s.Mode) {
|
|
cfg.Logger.Warn("Invalid zanzana mode", "expected", validModes, "got", s.Mode)
|
|
s.Mode = "embedded"
|
|
}
|
|
|
|
s.Addr = sec.Key("address").MustString("")
|
|
|
|
cfg.Zanzana = s
|
|
}
|