From 90f223270012a85993029a03f80685bb7613458a Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 26 Nov 2012 12:14:43 +0000 Subject: Updated to make the requirement of redis soft, as it will probably be not used. --- lib/custodian/alerts/redis-state.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb index 1b57b2e..b2243f7 100644 --- a/lib/custodian/alerts/redis-state.rb +++ b/lib/custodian/alerts/redis-state.rb @@ -1,5 +1,3 @@ - - # # The redis-alerter. # @@ -14,7 +12,7 @@ module Custodian module Alerter - class AlertRedis < AlertFactory + class RedisAlert < AlertFactory # # The test this alerter cares about @@ -26,22 +24,25 @@ module Custodian # attr_reader :redis + attr_reader :available # # Constructor - save the test-object away & instantiate # the redis connection. # def initialize( obj ) - - begin - require 'rubygems' - require 'redis' - rescue LoadError - raise "ERROR Loading redis rubygem!" - end - - @test = obj - @redis = Redis.new + @available = true + + begin + require 'rubygems' + require 'redis' + rescue + puts "LOADING redis failed" + @available = false + end + + @test = obj + @redis = Redis.new( ) if ( @available ) end @@ -50,6 +51,7 @@ module Custodian # Store an alert in redis # def raise + return if ( ! @available ) # hostname + test-type host = @test.target @@ -69,6 +71,7 @@ module Custodian # Clear an alert in redis # def clear + return if ( ! @available ) # hostname + test-type host = @test.target -- cgit v1.2.1