Class: AcidicJob::Workflow
- Inherits:
-
Object
- Object
- AcidicJob::Workflow
- Defined in:
- lib/acidic_job/workflow.rb
Instance Method Summary collapse
- #execute_current_step ⇒ Object
-
#initialize(run, job, step_result = nil) ⇒ Workflow
constructor
{ “step 1”: { does: “step 1”, awaits: [], then: “step 2” }, … }.
- #progress_to_next_step ⇒ Object
Constructor Details
#initialize(run, job, step_result = nil) ⇒ Workflow
{ “step 1”: { does: “step 1”, awaits: [], then: “step 2” }, … }
6 7 8 9 10 |
# File 'lib/acidic_job/workflow.rb', line 6 def initialize(run, job, step_result = nil) @run = run @job = job @step_result = step_result end |
Instance Method Details
#execute_current_step ⇒ Object
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 |
# File 'lib/acidic_job/workflow.rb', line 12 def execute_current_step rescued_error = false begin run_current_step rescue StandardError => e rescued_error = e raise e ensure if rescued_error begin @run.store_error!(rescued_error) rescue StandardError => e # We're already inside an error condition, so swallow any additional # errors from here and just send them to logs. AcidicJob.logger.error("Failed to unlock AcidicJob::Run #{@run.id} because of #{e}.") end end end # be sure to return the `step_result` # which is set by `run_current_step` # which runs the (wrapped) current step method @step_result end |
#progress_to_next_step ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/acidic_job/workflow.rb', line 38 def progress_to_next_step return if @run.current_step_finished? return run_step_result unless @run.next_step_finishes? @job.run_callbacks :finish do run_step_result end end |