Class: OkComputer::RabbitmqCheck
- Defined in:
- lib/ok_computer/built_in_checks/rabbitmq_check.rb
Constant Summary collapse
- ConnectionFailed =
Class.new(StandardError)
Constants inherited from Check
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #time
Instance Method Summary collapse
- #check ⇒ Object
- #connection_status ⇒ Object
-
#initialize(url = nil) ⇒ RabbitmqCheck
constructor
A new instance of RabbitmqCheck.
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
Constructor Details
#initialize(url = nil) ⇒ RabbitmqCheck
Returns a new instance of RabbitmqCheck.
5 6 7 |
# File 'lib/ok_computer/built_in_checks/rabbitmq_check.rb', line 5 def initialize(url = nil) @url = url || ENV['CLOUDAMQP_URL'] || ENV['AMQP_HOST'] end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/ok_computer/built_in_checks/rabbitmq_check.rb', line 3 def url @url end |
Instance Method Details
#check ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ok_computer/built_in_checks/rabbitmq_check.rb', line 9 def check "Connected Successfully" "Rabbit Connection Status: (#{connection_status})" rescue => e mark_failure "Error: '#{e}'" end |
#connection_status ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ok_computer/built_in_checks/rabbitmq_check.rb', line 17 def connection_status connection = Bunny.new(@url) connection.start status = connection.status connection.close status rescue => e raise ConnectionFailed, e end |