Class: LcpRuby::BackgroundJobs::StepsExecutor
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- LcpRuby::BackgroundJobs::StepsExecutor
- Defined in:
- lib/lcp_ruby/background_jobs/steps_executor.rb
Instance Attribute Summary
Attributes inherited from BaseHandler
Instance Method Summary collapse
Methods inherited from BaseHandler
#attach_result!, #check_cancellation!, #flush_log!, #initialize, #log!, #params, #set_result_url!, #target_record, #triggered_by, #update_progress!
Constructor Details
This class inherits a constructor from LcpRuby::BackgroundJobs::BaseHandler
Instance Method Details
#perform ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lcp_ruby/background_jobs/steps_executor.rb', line 4 def perform total = definition.steps.size on_error = definition.on_step_error definition.steps.each_with_index do |step_config, index| check_cancellation! step_num = index + 1 action_name = step_config["action"] log!("Step #{step_num}/#{total}: #{action_name}", level: :info) action_class = Declarative::Registry.action_for(action_name) unless action_class = "Declarative action '#{action_name}' not found (step #{step_num})" if on_error == "continue" log!(, level: :error) next else raise HandlerClassNotFoundError, end end step_definition = build_step_definition(step_config) action = action_class.new(execution, step_definition) begin action.perform rescue => e log!("Step #{step_num}/#{total} failed: #{e.}", level: :error) raise unless on_error == "continue" end progress = (step_num * 100) / total update_progress!(progress) end end |