diff --git a/cmd/api/main.go b/cmd/api/main.go index 277e0d47b..4d18c1529 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -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") diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 6abba786d..fe5ba230b 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -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 { diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 4c43096f7..d99306cb4 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -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()