Sha256: 524fb7f25dbd6bbff54f39e47b8d305ecd1e48d1d910cf660cf6940291ab76c3
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
module IsItWorking class RsolrCheck def initialize(options={}) @client = options[:client] raise ArgumentError.new(":client not specified") unless @client @host = @client.uri @alias = options[:alias] || @host end 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 def luke @luke ||= begin @client.luke(:show => 'schema', :numTerms => 0)['index'] rescue {} end end 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 def ping @client.head("admin/ping").response[:status] == 200 rescue false end end end
Version data entries
3 entries across 3 versions & 1 rubygems