Class: Patriot::Command::PostProcessor::Retrial
- Defined in:
- lib/patriot/command/post_processor/retrial.rb
Constant Summary collapse
- COUNT_PROP_KEY =
:count
- INTERVAL_PROP_KEY =
:interval
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
declare_post_processor_name, #initialize, #process, #process_success
Constructor Details
This class inherits a constructor from Patriot::Command::PostProcessor::Base
Instance Method Details
#process_failure(cmd, worker, job_ticket) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/patriot/command/post_processor/retrial.rb', line 16 def process_failure(cmd, worker, job_ticket) found = false cmd.post_processors.each do |pp| next unless pp.is_a?(Patriot::Command::PostProcessor::Retrial) raise "multiple retry processors in #{cmd.job_id}" if found found = true # count first attempt in pp.props[COUNT_PROP_KEY] = pp.props[COUNT_PROP_KEY] - 1 return true if pp.props[COUNT_PROP_KEY] < 1 cmd.start_datetime = Time.now + pp.props[INTERVAL_PROP_KEY] end job = cmd.to_job current_config = worker.job_store.get_job(job.job_id) job[Patriot::Command::PRODUCTS_ATTR] = current_config[Patriot::Command::PRODUCTS_ATTR] job[Patriot::Command::REQUISITES_ATTR] = current_config[Patriot::Command::REQUISITES_ATTR] job[Patriot::Command::STATE_ATTR] = Patriot::JobStore::JobState::WAIT worker.job_store.register(Time.now.to_i, [job]) return false end |
#validate_props(props) ⇒ Object
11 12 13 14 |
# File 'lib/patriot/command/post_processor/retrial.rb', line 11 def validate_props(props) raise "#{COUNT_PROP_KEY} is not specified" unless props.has_key?(COUNT_PROP_KEY) raise "#{INTERVAL_PROP_KEY} is not specified" unless props.has_key?(INTERVAL_PROP_KEY) end |