class OkComputer::SolrCheck
This class performs a health check on Solr instance using the admin/ping handler.
Attributes
Public Class Methods
Source
# 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
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.
Calls superclass method
OkComputer::HttpCheck::new
Public Instance Methods
Source
# File lib/ok_computer/built_in_checks/solr_check.rb, line 17 def check if ping? mark_message "Solr ping reported success" else mark_failure mark_message "Solr ping reported failure" end rescue => e mark_failure mark_message "Error: '#{e}'" end
Public: Return the status of Solr
Source
# 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
Public: Returns true if Solr’s ping returned OK, otherwise false