Class: RabbitMQ::HTTP::HealthChecks
- Inherits:
-
Object
- Object
- RabbitMQ::HTTP::HealthChecks
- Defined in:
- lib/rabbitmq/http/client/health_checks.rb
Constant Summary collapse
- TIME_UNITS =
%w(days weeks months years)
Instance Method Summary collapse
- #check_alarms ⇒ Object
- #check_certificate_expiration(within, unit) ⇒ Object
- #check_if_node_is_mirror_sync_critical ⇒ Object
- #check_if_node_is_quorum_critical ⇒ Object
- #check_local_alarms ⇒ Object
- #check_port_listener(port) ⇒ Object
- #check_protocol_listener(proto) ⇒ Object
- #check_virtual_hosts ⇒ Object
- #health_check_for(path) ⇒ Object
-
#initialize(client) ⇒ HealthChecks
constructor
A new instance of HealthChecks.
Constructor Details
#initialize(client) ⇒ HealthChecks
Returns a new instance of HealthChecks.
11 12 13 14 15 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 11 def initialize(client) @client = client @request_helper = @client.request_helper @response_helper = @client.response_helper end |
Instance Method Details
#check_alarms ⇒ Object
17 18 19 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 17 def check_alarms health_check_for("health/checks/alarms") end |
#check_certificate_expiration(within, unit) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 47 def check_certificate_expiration(within, unit) raise ArgumentError.new("supported time units are #{TIME_UNITS.join(', ')}, given: #{unit}") if !TIME_UNITS.include?(unit) raise ArgumentError.new("the number of time units must be a positive integer") if within <= 0 health_check_for("health/checks/certificate-expiration/#{@request_helper.encode_uri_path_segment(within)}/#{@request_helper.encode_uri_path_segment(unit)}") end |
#check_if_node_is_mirror_sync_critical ⇒ Object
33 34 35 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 33 def check_if_node_is_mirror_sync_critical health_check_for("health/checks/node-is-mirror-sync-critical") end |
#check_if_node_is_quorum_critical ⇒ Object
29 30 31 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 29 def check_if_node_is_quorum_critical health_check_for("health/checks/node-is-quorum-critical") end |
#check_local_alarms ⇒ Object
21 22 23 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 21 def check_local_alarms health_check_for("health/checks/local-alarms") end |
#check_port_listener(port) ⇒ Object
37 38 39 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 37 def check_port_listener(port) health_check_for("health/checks/port-listener/#{encode_uri_path_segment(port)}") end |
#check_protocol_listener(proto) ⇒ Object
41 42 43 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 41 def check_protocol_listener(proto) health_check_for("health/checks/protocol-listener/#{encode_uri_path_segment(proto)}") end |
#check_virtual_hosts ⇒ Object
25 26 27 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 25 def check_virtual_hosts health_check_for("health/checks/virtual-hosts") end |
#health_check_for(path) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rabbitmq/http/client/health_checks.rb', line 55 def health_check_for(path) begin _ = @response_helper.decode_resource(@client.connection.get(path)) [true, nil] rescue Faraday::ServerError => se # health check endpoints respond with a 503 if the server fails if se.response_status == 503 [false, @response_helper.decode_response_body(se.response[:body])] else raise se end end end |