Class: Rearview::AlertsHandler

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/rearview/alerts_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger

Constructor Details

#initialize(job, monitor_results) ⇒ AlertsHandler

Returns a new instance of AlertsHandler.



6
7
8
9
# File 'lib/rearview/alerts_handler.rb', line 6

def initialize(job,monitor_results)
  @job = job
  @monitor_results = monitor_results
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



5
6
7
# File 'lib/rearview/alerts_handler.rb', line 5

def job
  @job
end

#monitor_resultObject (readonly)

Returns the value of attribute monitor_result.



5
6
7
# File 'lib/rearview/alerts_handler.rb', line 5

def monitor_result
  @monitor_result
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rearview/alerts_handler.rb', line 10

def run
  if Rearview.config.alerts_enabled?
    Rearview.alert_clients.each do |client|
      begin
        alert_agent = client.new
        alert_agent.alert(@job,@monitor_results)
      rescue
        logger.error "#{self} #{client} failed: #{$!}\n#{$@.join("\n")}"
      end
    end
  end
  self
end