Class: IsItWorking::RsolrCheck
- Inherits:
-
Object
- Object
- IsItWorking::RsolrCheck
- Defined in:
- lib/is_it_working/checks/rsolr_check.rb
Instance Method Summary collapse
- #call(status) ⇒ Object
-
#initialize(options = {}) ⇒ RsolrCheck
constructor
A new instance of RsolrCheck.
- #luke ⇒ Object
- #ping ⇒ Object
- #registry ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RsolrCheck
Returns a new instance of RsolrCheck.
3 4 5 6 7 8 |
# File 'lib/is_it_working/checks/rsolr_check.rb', line 3 def initialize(={}) @client = [:client] raise ArgumentError.new(":client not specified") unless @client @host = @client.uri @alias = [:alias] || @host end |
Instance Method Details
#call(status) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/is_it_working/checks/rsolr_check.rb', line 10 def call(status) if ping status.ok("service active") unless luke.empty? status.info("numDocs: #{luke['numDocs']}") status.info("lastModified: #{luke['lastModified']}") end registry.each do |name, text| status.info("#{name} - #{text}") end else status.fail("service down") end end |
#luke ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/is_it_working/checks/rsolr_check.rb', line 25 def luke @luke ||= begin @client.luke(:show => 'schema', :numTerms => 0)['index'] rescue {} end end |
#ping ⇒ Object
48 49 50 51 52 |
# File 'lib/is_it_working/checks/rsolr_check.rb', line 48 def ping @client.head("admin/ping").response[:status] == 200 rescue false end |
#registry ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/is_it_working/checks/rsolr_check.rb', line 33 def registry @registry ||= begin resp = @client.get 'admin/registry.jsp', :params => { :wt => 'xml' } doc = Nokogiri::XML resp h = {} doc.xpath('/solr/*').each do |node| next if node.name == "solr-info" h[node.name] = node.text end h rescue {} end end |