+
+func (a *AlarmAdapter) Run(sdlcheck bool) {
+ app.Logger.SetMdc("alarmAdapter", fmt.Sprintf("%s:%s", Version, Hash))
+ app.SetReadyCB(func(d interface{}) { a.rmrReady = true }, true)
+ app.Resource.InjectStatusCb(a.StatusCB)
+
+ app.Resource.InjectRoute("/ric/v1/alarms", a.RaiseAlarm, "POST")
+ app.Resource.InjectRoute("/ric/v1/alarms", a.ClearAlarm, "DELETE")
+ app.Resource.InjectRoute("/ric/v1/alarms/active", a.GetActiveAlarms, "GET")
+ app.Resource.InjectRoute("/ric/v1/alarms/history", a.GetAlarmHistory, "GET")
+
+ // Start background timer for re-raising alerts
+ a.postClear = sdlcheck
+ go a.StartAlertTimer()
+
+ app.RunWithParams(a, sdlcheck)
+}
+
+func NewAlarmAdapter(amHost string, alertInterval int) *AlarmAdapter {
+ if alertInterval == 0 {
+ alertInterval = viper.GetInt("controls.promAlertManager.alertInterval")
+ }
+
+ if amHost == "" {
+ amHost = viper.GetString("controls.promAlertManager.address")
+ }
+
+ return &AlarmAdapter{
+ rmrReady: false,
+ amHost: amHost,
+ amBaseUrl: viper.GetString("controls.promAlertManager.baseUrl"),
+ amSchemes: []string{viper.GetString("controls.promAlertManager.schemes")},
+ alertInterval: alertInterval,
+ activeAlarms: make([]alarm.Alarm, 0),
+ alarmHistory: make([]alarm.Alarm, 0),
+ }
+}
+
+// Main function
+func main() {
+ NewAlarmAdapter("", 0).Run(true)
+}