Class: Dynflow::Director::SequentialManager

Inherits:
Object
  • Object
show all
Defined in:
lib/dynflow/director/sequential_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(world, execution_plan) ⇒ SequentialManager

Returns a new instance of SequentialManager.



7
8
9
10
11
# File 'lib/dynflow/director/sequential_manager.rb', line 7

def initialize(world, execution_plan)
  @world          = world
  @execution_plan = execution_plan
  @done           = false
end

Instance Attribute Details

#execution_planObject (readonly)

Returns the value of attribute execution_plan.



5
6
7
# File 'lib/dynflow/director/sequential_manager.rb', line 5

def execution_plan
  @execution_plan
end

#worldObject (readonly)

Returns the value of attribute world.



5
6
7
# File 'lib/dynflow/director/sequential_manager.rb', line 5

def world
  @world
end

Instance Method Details

#done!Object



46
47
48
# File 'lib/dynflow/director/sequential_manager.rb', line 46

def done!
  @done = true
end

#done?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/dynflow/director/sequential_manager.rb', line 50

def done?
  @done
end

#finalizeObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dynflow/director/sequential_manager.rb', line 22

def finalize
  reset_finalize_steps
  unless execution_plan.error?
    step_id = execution_plan.finalize_flow.all_step_ids.first
    action_class = execution_plan.steps[step_id].action_class
    world.middleware.execute(:finalize_phase, action_class, execution_plan) do
      dispatch(execution_plan.finalize_flow)
    end
  end
  @done = true
end

#finalize_stepsObject



34
35
36
37
38
# File 'lib/dynflow/director/sequential_manager.rb', line 34

def finalize_steps
  execution_plan.finalize_flow.all_step_ids.map do |step_id|
    execution_plan.steps[step_id]
  end
end

#reset_finalize_stepsObject



40
41
42
43
44
# File 'lib/dynflow/director/sequential_manager.rb', line 40

def reset_finalize_steps
  finalize_steps.each do |step|
    step.state = :pending if [:success, :error].include? step.state
  end
end

#runObject



13
14
15
16
17
18
19
20
# File 'lib/dynflow/director/sequential_manager.rb', line 13

def run
  with_state_updates do
    dispatch(execution_plan.run_flow)
    finalize
  end

  return execution_plan
end