Class: Dynflow::Executors::Parallel::SequentialManager

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(world, execution_plan) ⇒ SequentialManager

Returns a new instance of SequentialManager.



6
7
8
9
10
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 6

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.



4
5
6
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 4

def execution_plan
  @execution_plan
end

#worldObject (readonly)

Returns the value of attribute world.



4
5
6
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 4

def world
  @world
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 44

def done?
  @done
end

#finalizeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 21

def finalize
  reset_finalize_steps
  unless execution_plan.error?
    world.transaction_adapter.transaction do
      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) do
        unless dispatch(execution_plan.finalize_flow)
          world.transaction_adapter.rollback
        end
      end
    end
  end
  @done = true
end

#reset_finalize_stepsObject



37
38
39
40
41
42
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 37

def reset_finalize_steps
  execution_plan.finalize_flow.all_step_ids.each do |step_id|
    step       = execution_plan.steps[step_id]
    step.state = :pending if [:success, :error].include? step.state
  end
end

#runObject



12
13
14
15
16
17
18
19
# File 'lib/dynflow/executors/parallel/sequential_manager.rb', line 12

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

  return execution_plan
end