X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fxapp.go;h=124fbcfa34aa1b5b973168d7d898837b02050a1a;hb=d1fcac7ec9fb1957caacda20d89bc5e4bd727412;hp=69d29649179c322b551bd03283ecddf0165b0f25;hpb=3e611c621fa048f5f7da7cab3d4c211b4686fcce;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go index 69d2964..124fbcf 100755 --- a/pkg/xapp/xapp.go +++ b/pkg/xapp/xapp.go @@ -29,22 +29,31 @@ type ReadyCB func(interface{}) var ( // XApp is an application instance - Rmr *RMRClient - Sdl *SDLClient - UeNib *UENIBClient - Rnib *RNIBClient - Resource *Router - Metric *Metrics - Logger *Log - Config Configurator + Rmr *RMRClient + Sdl *SDLClient + Rnib *RNIBClient + Resource *Router + Metric *Metrics + Logger *Log + Config Configurator + Subscription *Subscriber + readyCb ReadyCB + readyCbParams interface{} ) func IsReady() bool { - return Rmr.IsReady() && Sdl.IsReady() + return Rmr != nil && Rmr.IsReady() && Sdl != nil && Sdl.IsReady() } func SetReadyCB(cb ReadyCB, params interface{}) { - Rmr.SetReadyCB(cb, params) + readyCb = cb + readyCbParams = params +} + +func xappReadyCb(params interface{}) { + if readyCb != nil { + readyCb(readyCbParams) + } } func init() { @@ -55,8 +64,7 @@ func init() { Resource = NewRouter() Config = Configurator{} Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router) - Rmr = NewRMRClient() - UeNib = NewUENIBClient() + Subscription = NewSubscriber(viper.GetString("subscription.host"), viper.GetInt("subscription.timeout")) if viper.IsSet("db.namespaces") { namespaces := viper.GetStringSlice("db.namespaces") @@ -71,11 +79,17 @@ func init() { } } -func Run(c MessageConsumer) { +func RunWithParams(c MessageConsumer, sdlcheck bool) { + Rmr = NewRMRClient() + Rmr.SetReadyCB(xappReadyCb, nil) go http.ListenAndServe(viper.GetString("local.host"), Resource.router) - Logger.Info(fmt.Sprintf("Xapp started, listening on: %s", viper.GetString("local.host"))) - - Sdl.TestConnection() + if sdlcheck { + Sdl.TestConnection() + } Rmr.Start(c) } + +func Run(c MessageConsumer) { + RunWithParams(c, true) +}