Class: Legion::Alerts::Engine
- Inherits:
-
Object
- Object
- Legion::Alerts::Engine
- Defined in:
- lib/legion/alerts.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #evaluate(event_name, payload = {}) ⇒ Object
-
#initialize(rules: []) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
31 32 33 |
# File 'lib/legion/alerts.rb', line 31 def rules @rules end |
Instance Method Details
#evaluate(event_name, payload = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/legion/alerts.rb', line 39 def evaluate(event_name, payload = {}) fired = [] @rules.each do |rule| next unless event_matches?(event_name, rule.event_pattern) Legion::Logging.debug "[Alerts] evaluating rule=#{rule.name} for event=#{event_name}" if defined?(Legion::Logging) next unless condition_met?(rule, event_name) next if in_cooldown?(rule) fire_alert(rule, event_name, payload) fired << rule.name end fired end |