func PublishConfigChange(appName, eventJson string) error {
channel := fmt.Sprintf("CM_UPDATE:%s", appName)
- if err := Sdl.StoreAndPublish(channel, eventJson, appName, eventJson); err != nil {
+ if err := SdlStorage.StoreAndPublish(getCmSdlNs(), channel, eventJson, appName, eventJson); err != nil {
Logger.Error("Sdl.Store failed: %v", err)
return err
}
return nil
}
+func ReadConfig(appName string) (map[string]interface{}, error) {
+ return SdlStorage.Read(getCmSdlNs(), appName)
+}
+
func GetPortData(pname string) (d PortData) {
var getPolicies = func(policies []interface{}) (plist []int) {
for _, p := range policies {
if pname == "http" {
d.Port = 8080
}
- if pname == "rmr-data" {
+ if pname == "rmrdata" {
d.Port = 4560
}
return
return
}
+func getCmSdlNs() string {
+ return fmt.Sprintf("cm/%s", viper.GetString("name"))
+}
+
func (*Configurator) SetSDLNotificationCB(appName string, sdlNotificationCb SDLNotificationCB) error {
- return Sdl.Subscribe(sdlNotificationCb, fmt.Sprintf("CM_UPDATE:%s", appName))
+ return SdlStorage.Subscribe(getCmSdlNs(), sdlNotificationCb, fmt.Sprintf("CM_UPDATE:%s", appName))
}
func (*Configurator) GetString(key string) string {
func (*Configurator) GetStringMap(key string) map[string]interface{} {
return viper.GetStringMap(key)
}
+
+func (*Configurator) IsSet(key string) bool {
+ return viper.IsSet(key)
+}