From 2327ff5ec0d848577ea9708e405dc7c70bf31537 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 12 Dec 2012 14:13:50 +0000 Subject: The dequeuing process passes the settings to the wroker. --- lib/custodian/worker.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb index 936c44b..11aa0e6 100644 --- a/lib/custodian/worker.rb +++ b/lib/custodian/worker.rb @@ -61,12 +61,18 @@ module Custodian attr_reader :logger + # + # The settings from the global configuration file + # + attr_reader :settings + + # # Constructor: Connect to the queue # - def initialize( server, alerter, logfile ) + def initialize( server, alerter, logfile, settings ) # Connect to the queue @queue = Beanstalk::Pool.new([server], "Custodian" ) @@ -77,6 +83,9 @@ module Custodian # Instantiate the logger. @logger = Logger.new( logfile, "daily" ) + # Save the settings + @settings = settings + # How many times to repeat a failing test @retry_count=5 @@ -214,10 +223,13 @@ module Custodian log_message( "Creating alerter: #{alerter}" ) alert = Custodian::AlertFactory.create( alerter, test ) - target = Custodian::Settings.instance().alerter_target( alerter ) + target = @settings.alerter_target( alerter ) + alert.set_target( target ) puts "Target for alert is #{target}" - alert.set_target( target ) + # give the alerter a reference to the settings object. + alert.set_settings( @settings ) + alert.raise() end end @@ -229,12 +241,15 @@ module Custodian def do_clear( test ) @alerter.split( "," ).each do |alerter| log_message( "Creating alerter: #{alerter}" ) - alert = Custodian::AlertFactory.create( alerter, test ) + alert = Custodian::AlertFactory.create( alerter, test ) - target = Custodian::Settings.instance().alerter_target( alerter ) + target = @settings.alerter_target( alerter ) + alert.set_target( target ) puts "Target for alert is #{target}" - alert.set_target( target ) + # give the alerter a reference to the settings object. + alert.set_settings( @settings ) + alert.clear() end end -- cgit v1.2.1