Class: Rack::ECG::Check::RedisConnection
- Inherits:
-
Object
- Object
- Rack::ECG::Check::RedisConnection
- Defined in:
- lib/rack/ecg/check/redis_connection.rb
Instance Attribute Summary collapse
-
#redis_instance ⇒ Object
readonly
Returns the value of attribute redis_instance.
Instance Method Summary collapse
-
#initialize(parameters = {}) ⇒ RedisConnection
constructor
Checks whether the given Redis client is currently connected to the database as identified by the
instance
option. - #result ⇒ Object
Constructor Details
#initialize(parameters = {}) ⇒ RedisConnection
Checks whether the given Redis client is currently connected to the database as identified by the instance
option.
13 14 15 |
# File 'lib/rack/ecg/check/redis_connection.rb', line 13 def initialize(parameters = {}) @redis_instance = parameters[:instance] end |
Instance Attribute Details
#redis_instance ⇒ Object (readonly)
Returns the value of attribute redis_instance.
7 8 9 |
# File 'lib/rack/ecg/check/redis_connection.rb', line 7 def redis_instance @redis_instance end |
Instance Method Details
#result ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rack/ecg/check/redis_connection.rb', line 17 def result value = "" status = Status::OK begin if redis_instance.nil? status = Status::ERROR value = "Redis instance parameters not found" elsif defined?(::Redis) value = redis_instance.connected? status = value ? Status::OK : Status::ERROR else status = Status::ERROR value = "Redis not found" end rescue => e status = Status::ERROR value = e. end Result.new(:redis, status, value.to_s) end |