Class: Railsmith::Pipeline::Runner
- Inherits:
-
Object
- Object
- Railsmith::Pipeline::Runner
- Defined in:
- lib/railsmith/pipeline/runner.rb
Overview
Walks a pipeline’s step definitions, invoking each step’s service and accumulating params across steps. Emits instrumentation events at each step boundary and for the overall pipeline run.
Execution is fail-fast: on the first step failure the runner invokes rollback handlers (in reverse order) for every previously completed step that declared a rollback:, then returns a failure Result annotated with :pipeline_name, :pipeline_step, and (when present) :rollback_failures in meta.
Param forwarding rule:
accumulated_params starts as the original params hash. After each
successful step, if result.value is a Hash, it is merged into
accumulated_params so the next step receives everything seen so far.
Steps with an inputs: mapping have source keys renamed to target keys
in the copy forwarded to that step; accumulated_params itself retains
the original key names.
Defined Under Namespace
Classes: ExecutedStep
Instance Method Summary collapse
-
#initialize(pipeline_class:, params:, context:) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(pipeline_class:, params:, context:) ⇒ Runner
Returns a new instance of Runner.
24 25 26 27 28 29 |
# File 'lib/railsmith/pipeline/runner.rb', line 24 def initialize(pipeline_class:, params:, context:) @pipeline_class = pipeline_class @context = context @accumulated_params = params.dup @executed_steps = [] end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/railsmith/pipeline/runner.rb', line 31 def run pipeline_name = @pipeline_class.pipeline_name started_at = clock_now result = execute_steps Instrumentation.instrument("pipeline", { pipeline: pipeline_name, status: result.success? ? :success : :failure, duration: clock_now - started_at }) result end |