Code Review
/
ric-plt
/
xapp-frame.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Support for subscription callback
[ric-plt/xapp-frame.git]
/
pkg
/
xapp
/
xapp.go
diff --git
a/pkg/xapp/xapp.go
b/pkg/xapp/xapp.go
old mode 100644
(file)
new mode 100755
(executable)
index
1fd7ad6
..
b63c8aa
--- a/
pkg/xapp/xapp.go
+++ b/
pkg/xapp/xapp.go
@@
-29,21
+29,32
@@
type ReadyCB func(interface{})
var (
// XApp is an application instance
var (
// XApp is an application instance
- Rmr *RMRClient
- Sdl *SDLClient
- 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
+ Alarm *AlarmClient
+ readyCb ReadyCB
+ readyCbParams interface{}
)
func IsReady() bool {
)
func IsReady() bool {
- return Rmr
.IsReady()
&& Sdl.IsReady()
+ return Rmr
!= nil && Rmr.IsReady() && Sdl != nil
&& Sdl.IsReady()
}
func SetReadyCB(cb ReadyCB, params interface{}) {
}
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() {
}
func init() {
@@
-54,7
+65,8
@@
func init() {
Resource = NewRouter()
Config = Configurator{}
Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router)
Resource = NewRouter()
Config = Configurator{}
Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router)
- Rmr = NewRMRClient()
+ Subscription = NewSubscriber(viper.GetString("subscription.host"), viper.GetInt("subscription.timeout"))
+ Alarm = NewAlarmClient(viper.GetString("alarm.MOId"), viper.GetString("alarm.APPId"))
if viper.IsSet("db.namespaces") {
namespaces := viper.GetStringSlice("db.namespaces")
if viper.IsSet("db.namespaces") {
namespaces := viper.GetStringSlice("db.namespaces")
@@
-69,11
+81,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)
go http.ListenAndServe(viper.GetString("local.host"), Resource.router)
-
Logger.Info(fmt.Sprintf("Xapp started, listening on: %s", viper.GetString("local.host")))
Logger.Info(fmt.Sprintf("Xapp started, listening on: %s", viper.GetString("local.host")))
-
- Sdl.TestConnection()
+ if sdlcheck {
+ Sdl.TestConnection()
+ }
Rmr.Start(c)
}
Rmr.Start(c)
}
+
+func Run(c MessageConsumer) {
+ RunWithParams(c, true)
+}