C rmr context is now protected. Stabilizes rmr usage with multithreads
[ric-plt/xapp-frame.git] / pkg / xapp / xapp.go
old mode 100644 (file)
new mode 100755 (executable)
index 45a3564..0ae9b02
@@ -36,6 +36,8 @@ var (
        Metric        *Metrics
        Logger        *Log
        Config        Configurator
+       Subscription  *Subscriber
+       Alarm         *AlarmClient
        readyCb       ReadyCB
        readyCbParams interface{}
 )
@@ -50,6 +52,8 @@ func SetReadyCB(cb ReadyCB, params interface{}) {
 }
 
 func xappReadyCb(params interface{}) {
+       Alarm = NewAlarmClient(viper.GetString("alarm.MOId"), viper.GetString("alarm.APPId"))
+
        if readyCb != nil {
                readyCb(readyCbParams)
        }
@@ -63,13 +67,14 @@ func init() {
        Resource = NewRouter()
        Config = Configurator{}
        Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router)
+       Subscription = NewSubscriber(viper.GetString("subscription.host"), viper.GetInt("subscription.timeout"))
 
        if viper.IsSet("db.namespaces") {
                namespaces := viper.GetStringSlice("db.namespaces")
-               if namespaces[0] != "" {
+               if len(namespaces) > 0 && namespaces[0] != "" {
                        Sdl = NewSDLClient(viper.GetStringSlice("db.namespaces")[0])
                }
-               if namespaces[1] != "" {
+               if len(namespaces) > 1 && namespaces[1] != "" {
                        Rnib = NewRNIBClient(viper.GetStringSlice("db.namespaces")[1])
                }
        } else {