pull/454/head^2
withchao 2 years ago
parent 1e65eb68c2
commit d5c747fc1a

@ -59,7 +59,7 @@ func run(port int) error {
}
fmt.Println("api init discov client success")
fmt.Println("api register public config to discov")
if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil {
if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil {
return err
}
fmt.Println("api register public config to discov success")

@ -7,10 +7,7 @@ import (
//go:embed version
var Version string
var Config struct {
config
Notification notification
}
var Config config
type CallBackConfig struct {
Enable bool `yaml:"enable"`
@ -268,6 +265,7 @@ type config struct {
MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"`
ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"`
} `yaml:"prometheus"`
Notification notification `yaml:"notification"`
}
type notification struct {

@ -87,7 +87,7 @@ func (c *config) GetConfFromRegistry(registry discoveryregistry.SvcDiscoveryRegi
}
func InitConfig(configFolderPath string) error {
err := Config.initConfig(&Config.config, FileName, configFolderPath)
err := Config.initConfig(&Config, FileName, configFolderPath)
if err != nil {
return err
}
@ -98,9 +98,9 @@ func InitConfig(configFolderPath string) error {
return nil
}
func EncodeConfig() []byte {
func (c *config) EncodeConfig() []byte {
buf := bytes.NewBuffer(nil)
if err := yaml.NewEncoder(buf).Encode(Config); err != nil {
if err := yaml.NewEncoder(buf).Encode(c); err != nil {
panic(err)
}
return buf.Bytes()

Loading…
Cancel
Save