Class: Burner::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/burner/pipeline.rb

Overview

The root package. A Pipeline contains the job configurations along with the steps. The steps reference jobs and tell you the order of the jobs to run. If steps is nil then all jobs will execute in their declared order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jobs: [], steps: nil) ⇒ Pipeline

Returns a new instance of Pipeline.



24
25
26
27
28
29
# File 'lib/burner/pipeline.rb', line 24

def initialize(jobs: [], steps: nil)
  @steps = JobSet
           .new(jobs)
           .jobs(steps)
           .map { |job| Step.new(job) }
end

Instance Attribute Details

#stepsObject (readonly)

Returns the value of attribute steps.



22
23
24
# File 'lib/burner/pipeline.rb', line 22

def steps
  @steps
end

Instance Method Details

#execute(output: Output.new, payload: Payload.new) ⇒ Object

The main entry-point for kicking off a pipeline.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/burner/pipeline.rb', line 32

def execute(output: Output.new, payload: Payload.new)
  output.write("Pipeline started with #{steps.length} step(s)")

  output_params(payload.params, output)
  output.ruler

  time_in_seconds = Benchmark.measure do
    steps.each do |step|
      step.perform(output, payload)

      if payload.halt_pipeline?
        output.detail('Payload was halted, ending pipeline.')
        break
      end
    end
  end.real.round(3)

  output.ruler
  output.write("Pipeline ended, took #{time_in_seconds} second(s) to complete")

  payload
end