Class: ConflowSpec::Runner

Inherits:
Object
  • Object
show all
Includes:
Conflow::Worker
Defined in:
lib/conflow_spec/runner.rb

Overview

Runs the flow and collects informations about it

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flow) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • flow (Conflow::Flow)

    instance of the flow



11
12
13
14
15
# File 'lib/conflow_spec/runner.rb', line 11

def initialize(flow)
  @flow = flow
  @queue = queue
  @performed_jobs = []
end

Instance Attribute Details

#flowObject (readonly)

Returns the value of attribute flow.



8
9
10
# File 'lib/conflow_spec/runner.rb', line 8

def flow
  @flow
end

#performed_jobsObject (readonly)

Returns the value of attribute performed_jobs.



8
9
10
# File 'lib/conflow_spec/runner.rb', line 8

def performed_jobs
  @performed_jobs
end

Instance Method Details

#runObject

Performs all jobs in the flow, saving results in #performed_jobs



18
19
20
21
22
23
24
25
26
27
# File 'lib/conflow_spec/runner.rb', line 18

def run
  until queue.empty?
    job = queue.pop

    perform(flow.id, job.id) do |worker_type, params|
      performed_jobs << [worker_type, params.to_h]
      fetch_result(job)
    end
  end
end