Class: SearchSolrTools::Helpers::HarvestStatus
- Inherits:
-
Object
- Object
- SearchSolrTools::Helpers::HarvestStatus
- Defined in:
- lib/search_solr_tools/helpers/harvest_status.rb
Constant Summary collapse
- INGEST_OK =
:ok
- HARVEST_NO_DOCS =
:harvest_none
- HARVEST_FAILURE =
:harvest_fail
- INGEST_ERR_INVALID_DOC =
:invalid
- INGEST_ERR_SOLR_ERROR =
:solr_error
- OTHER_ERROR =
:other
- PING_SOLR =
used for initialize only
:ping_solr
- PING_SOURCE =
used for initialize only
:ping_source
- ERROR_STATUS =
[HARVEST_NO_DOCS, HARVEST_FAILURE, INGEST_ERR_INVALID_DOC, INGEST_ERR_SOLR_ERROR, OTHER_ERROR].freeze
Instance Attribute Summary collapse
-
#ping_solr ⇒ Object
Returns the value of attribute ping_solr.
-
#ping_source ⇒ Object
Returns the value of attribute ping_source.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(init_info = {}) ⇒ HarvestStatus
constructor
init_info is an optional hash that contains the various status keys and the documents to associate with them.
- #ok? ⇒ Boolean
- #record_status(status, count = 1) ⇒ Object
Constructor Details
#initialize(init_info = {}) ⇒ HarvestStatus
init_info is an optional hash that contains the various status keys and the documents to associate with them
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |
Instance Attribute Details
#ping_solr ⇒ Object
Returns the value of attribute ping_solr.
17 18 19 |
# File 'lib/search_solr_tools/helpers/harvest_status.rb', line 17 def ping_solr @ping_solr end |
#ping_source ⇒ Object
Returns the value of attribute ping_source.
17 18 19 |
# File 'lib/search_solr_tools/helpers/harvest_status.rb', line 17 def ping_source @ping_source end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
18 19 20 |
# File 'lib/search_solr_tools/helpers/harvest_status.rb', line 18 def status @status end |
Instance Method Details
#ok? ⇒ Boolean
40 41 42 43 |
# 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) ⇒ Object
36 37 38 |
# File 'lib/search_solr_tools/helpers/harvest_status.rb', line 36 def record_status(status, count = 1) @status[status] += count end |