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 init discov client success")
fmt.Println("api register public config to discov") 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 return err
} }
fmt.Println("api register public config to discov success") fmt.Println("api register public config to discov success")

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

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

Loading…
Cancel
Save