grafana/pkg/setting/settings_zanzana.go
Karl Persson 606a74d0af
Zanzana: Initial work to run openFGA as embedded or standalone service (#89211)
* 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>
2024-06-18 10:04:18 +02:00

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
}