Reworks recipients.lua as static rather than (useless) instance

This commit is contained in:
Simone Mainardi 2020-09-23 15:03:07 +02:00
parent 8f7ab1af85
commit 6c1280a8e5
17 changed files with 132 additions and 166 deletions

View file

@ -11,7 +11,6 @@ local json = require("dkjson")
local alert_consts = require("alert_consts")
local os_utils = require("os_utils")
local recipients = require "recipients"
local recipients_instance = recipients:create()
local do_trace = false
local alerts_api = {}
@ -183,7 +182,7 @@ function alerts_api.store(entity_info, type_info, when)
interface.incTotalHostAlerts(entity_info.alert_entity_val, type_info.alert_type.alert_key)
end
recipients_instance:dispatch_notification(alert_to_store, current_script)
recipients.dispatch_notification(alert_to_store, current_script)
return(true)
end
@ -320,7 +319,7 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts)
-- same 100 alerts will be triggered again as soon as ntopng is restarted, causing
-- 100 trigger notifications to be emitted twice. This check is to prevent such behavior.
if not is_trigger_notified(triggered) then
recipients_instance:dispatch_notification(triggered, current_script)
recipients.dispatch_notification(triggered, current_script)
mark_trigger_notified(triggered)
end
@ -390,7 +389,7 @@ function alerts_api.release(entity_info, type_info, when, cur_alerts)
addAlertPoolInfo(entity_info, released)
recipients_instance:dispatch_notification(released, current_script)
recipients.dispatch_notification(released, current_script)
mark_release_notified(released)
return(true)