Class: Dynflow::Director::ExecutionPlanManager
- Inherits:
-
Object
- Object
- Dynflow::Director::ExecutionPlanManager
- Includes:
- Algebrick::Matching, Algebrick::TypeCheck
- Defined in:
- lib/dynflow/director/execution_plan_manager.rb
Instance Attribute Summary collapse
-
#execution_plan ⇒ Object
readonly
Returns the value of attribute execution_plan.
-
#future ⇒ Object
readonly
Returns the value of attribute future.
Instance Method Summary collapse
- #done? ⇒ Boolean
- #event(event) ⇒ Object
-
#initialize(world, execution_plan, future) ⇒ ExecutionPlanManager
constructor
A new instance of ExecutionPlanManager.
- #prepare_next_step(step) ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #terminate ⇒ Object
-
#what_is_next(work) ⇒ Array<WorkItem>
Of Work items to continue with.
Constructor Details
#initialize(world, execution_plan, future) ⇒ ExecutionPlanManager
Returns a new instance of ExecutionPlanManager.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 11 def initialize(world, execution_plan, future) @world = Type! world, World @execution_plan = Type! execution_plan, ExecutionPlan @future = Type! future, Concurrent::Promises::ResolvableFuture @running_steps_manager = RunningStepsManager.new(world) unless [:planned, :paused].include? execution_plan.state raise "execution_plan is not in pending or paused state, it's #{execution_plan.state}" end execution_plan.update_state(:running) end |
Instance Attribute Details
#execution_plan ⇒ Object (readonly)
Returns the value of attribute execution_plan.
9 10 11 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 9 def execution_plan @execution_plan end |
#future ⇒ Object (readonly)
Returns the value of attribute future.
9 10 11 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 9 def future @future end |
Instance Method Details
#done? ⇒ Boolean
74 75 76 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 74 def done? (!@run_manager || @run_manager.done?) && (!@finalize_manager || @finalize_manager.done?) end |
#event(event) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 66 def event(event) Type! event, Event unless event.execution_plan_id == @execution_plan.id raise "event #{event.inspect} doesn't belong to plan #{@execution_plan.id}" end @running_steps_manager.event(event) end |
#prepare_next_step(step) ⇒ Object
34 35 36 37 38 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 34 def prepare_next_step(step) StepWorkItem.new(execution_plan.id, step, step.queue, @world.id).tap do |work| @running_steps_manager.add(step, work) end end |
#restart ⇒ Object
28 29 30 31 32 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 28 def restart @run_manager = nil @finalize_manager = nil start end |
#start ⇒ Object
23 24 25 26 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 23 def start raise "The future was already set" if @future.resolved? start_run or start_finalize or finish end |
#terminate ⇒ Object
78 79 80 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 78 def terminate @running_steps_manager.terminate end |
#what_is_next(work) ⇒ Array<WorkItem>
Returns of Work items to continue with.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 41 def what_is_next(work) Type! work, WorkItem case work when StepWorkItem step = work.step update_steps([step]) suspended, work = @running_steps_manager.done(step) work = compute_next_from_step(step) unless suspended work when FinalizeWorkItem if work.finalize_steps_data steps = work.finalize_steps_data.map do |step_data| Serializable.from_hash(step_data, execution_plan.id, @world) end update_steps(steps) end raise "Finalize work item without @finalize_manager ready" unless @finalize_manager @finalize_manager.done! finish else raise "Unexpected work #{work}" end end |