From 432205b7cef58be0d23d3ead15b4e131a3a91893 Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Tue, 30 May 2023 13:52:52 +0300 Subject: [PATCH] RunParams as struct to have possible to extend later. -DisableAlarmClient mostly for alarm manager to avoid alarmclient@xapp-frame init Signed-off-by: Juha Hyttinen Change-Id: Idf56608303a7fa57b3739dc912b6613b7bc0edbb --- pkg/xapp/xapp.go | 57 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go index d08e1cf..439c177 100755 --- a/pkg/xapp/xapp.go +++ b/pkg/xapp/xapp.go @@ -48,22 +48,23 @@ type ShutdownCB func() var ( // XApp is an application instance - Rmr *RMRClient - Sdl *SDLClient - SdlStorage *SDLStorage - Rnib *RNIBClient - Resource *Router - Metric *Metrics - Logger *Log - Config Configurator - Subscription *Subscriber - Alarm *AlarmClient - Util *Utils - readyCb ReadyCB - readyCbParams interface{} - shutdownCb ShutdownCB - shutdownFlag int32 - shutdownCnt int32 + Rmr *RMRClient + Sdl *SDLClient + SdlStorage *SDLStorage + Rnib *RNIBClient + Resource *Router + Metric *Metrics + Logger *Log + Config Configurator + Subscription *Subscriber + Alarm *AlarmClient + Util *Utils + readyCb ReadyCB + readyCbParams interface{} + shutdownCb ShutdownCB + shutdownFlag int32 + shutdownCnt int32 + disableAlarmClient bool ) var startTime time.Time @@ -86,7 +87,9 @@ func SetReadyCB(cb ReadyCB, params interface{}) { } func XappReadyCb(params interface{}) { - Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name")) + if disableAlarmClient == false { + Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name")) + } if readyCb != nil { readyCb(readyCbParams) } @@ -317,7 +320,19 @@ func GetIpAddress() (string, error) { return "", fmt.Errorf("Interface (%s) couldn't find ip", ifname) } -func RunWithParams(c MessageConsumer, sdlcheck bool) { +type RunParams struct { + SdlCheck bool + DisableAlarmClient bool +} + +func RunWithRunParams(c MessageConsumer, params RunParams) { + + if params.DisableAlarmClient { + disableAlarmClient = true + } else { + disableAlarmClient = false + } + Rmr = NewRMRClient() Rmr.SetReadyCB(XappReadyCb, nil) @@ -334,7 +349,7 @@ func RunWithParams(c MessageConsumer, sdlcheck bool) { go http.ListenAndServe(host, Resource.router) Logger.Info(fmt.Sprintf("Xapp started, listening on: %s", host)) - if sdlcheck { + if params.SdlCheck { SdlStorage.TestConnection(viper.GetString("controls.db.namespace")) } go registerXapp() @@ -342,6 +357,10 @@ func RunWithParams(c MessageConsumer, sdlcheck bool) { Rmr.Start(c) } +func RunWithParams(c MessageConsumer, sdlcheck bool) { + RunWithRunParams(c, RunParams{SdlCheck: sdlcheck, DisableAlarmClient: false}) +} + func Run(c MessageConsumer) { RunWithParams(c, true) } -- 2.16.6