Class: OkComputer::SolrCheck
- Defined in:
- lib/ok_computer/built_in_checks/solr_check.rb
Overview
This class performs a health check on Solr instance using the admin/ping handler.
Constant Summary
Constants inherited from HttpCheck
Constants inherited from Check
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Attributes inherited from HttpCheck
Attributes inherited from Check
#failure_occurred, #message, #registrant_name
Instance Method Summary collapse
-
#check ⇒ Object
Public: Return the status of Solr.
-
#initialize(host, request_timeout = 5) ⇒ SolrCheck
constructor
Public: Initialize a new Solr check.
-
#ping? ⇒ Boolean
Public: Returns true if Solr’s ping returned OK, otherwise false.
Methods inherited from HttpCheck
Methods inherited from Check
#clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text
Constructor Details
#initialize(host, request_timeout = 5) ⇒ SolrCheck
Public: Initialize a new Solr check.
host - The hostname of Solr request_timeout - How long to wait to connect before timing out. Defaults to 5 seconds.
11 12 13 14 15 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 11 def initialize(host, request_timeout = 5) @host = URI(host) ping_url ||= URI("#{host}/admin/ping") super(ping_url, request_timeout) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 5 def host @host end |
Instance Method Details
#check ⇒ Object
Public: Return the status of Solr
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 18 def check if ping? "Solr ping reported success" else mark_failure "Solr ping reported failure" end rescue => e mark_failure "Error: '#{e}'" end |
#ping? ⇒ Boolean
Public: Returns true if Solr’s ping returned OK, otherwise false
31 32 33 34 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 31 def ping? response = perform_request !!(response =~ %r(<str name="status">OK</str>)) end |