Class: Ductwork::Step
- Inherits:
-
Record
- Object
- Record
- Ductwork::Step
- Defined in:
- lib/ductwork/models/step.rb
Constant Summary collapse
- ADVANCEABLE_STATUSES =
The statuses that mean this step is done running and its branch is ready to be advanced:
advancing(the job succeeded) orfailed(the job exhausted its retry or crash budget). Shared by branch candidate selection, branch claiming, and the guard inBranch#advance!. %w[advancing failed].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #context ⇒ Object
- #run_id ⇒ Object
-
#terminal_result_type ⇒ Object
The result_type of the most recent execution to finish for this step's job, used to distinguish why a step failed (e.g.
errored!writes "failure",crashed!writes "process_crashed").
Class Method Details
.build_for_execution(run_id) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/ductwork/models/step.rb', line 43 def self.build_for_execution(run_id, *, **) instance = allocate instance.instance_variable_set(:@run_id, run_id) instance.send(:initialize, *, **) instance end |
Instance Method Details
#context ⇒ Object
69 70 71 |
# File 'lib/ductwork/models/step.rb', line 69 def context @_context ||= Ductwork::Context.new(run_id) end |
#run_id ⇒ Object
52 53 54 |
# File 'lib/ductwork/models/step.rb', line 52 def run_id @run_id || (@attributes && super) end |
#terminal_result_type ⇒ Object
The result_type of the most recent execution to finish for this step's
job, used to distinguish why a step failed (e.g. errored! writes
"failure", crashed! writes "process_crashed"). Returns nil when no
execution has produced a result yet.
60 61 62 63 64 65 66 67 |
# File 'lib/ductwork/models/step.rb', line 60 def terminal_result_type return if job.blank? job.executions .joins(:result) .order(created_at: :desc) .pick("ductwork_results.result_type") end |