class SearchSolrTools::Helpers::HarvestStatus

Constants

ERROR_STATUS
HARVEST_FAILURE
HARVEST_NO_DOCS
INGEST_ERR_INVALID_DOC
INGEST_ERR_SOLR_ERROR
INGEST_OK
OTHER_ERROR
PING_SOLR
PING_SOURCE

Attributes

ping_solr[RW]
ping_source[RW]
status[R]

Public Class Methods

new(init_info = {}) click to toggle source

init_info is an optional hash that contains the various status keys and the documents to associate with them

# File lib/search_solr_tools/helpers/harvest_status.rb, line 22
def initialize(init_info = {})
  @status = { INGEST_OK => 0 }
  @ping_solr = true
  @ping_source = true
  ERROR_STATUS.each { |s| @status[s] = 0 }

  init_info.each do |key, count|
    @status[key] = count if @status.include? key
  end

  @ping_solr = init_info[PING_SOLR] if init_info.include? PING_SOLR
  @ping_source = init_info[PING_SOURCE] if init_info.include? PING_SOURCE
end

Public Instance Methods

ok?() click to toggle source
# File lib/search_solr_tools/helpers/harvest_status.rb, line 40
def ok?
  ERROR_STATUS.each { |s| return false unless (@status[s]).zero? }
  @ping_solr && @ping_source
end
record_status(status, count = 1) click to toggle source
# File lib/search_solr_tools/helpers/harvest_status.rb, line 36
def record_status(status, count = 1)
  @status[status] += count
end