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
#basic_auth_password, #basic_auth_username, #request_timeout, #url
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #time
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
#basic_auth_options, #parse_url, #perform_request
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
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 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 11 def initialize(host, request_timeout = 5) @host = URI(host) super("#{host}/admin/ping", 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
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 17 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
30 31 32 33 |
# File 'lib/ok_computer/built_in_checks/solr_check.rb', line 30 def ping? response = perform_request !!(response =~ Regexp.union(%r(<str name="status">OK</str>), %r("status":"OK"))) end |