forked from Dynflow/dynflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecution_plan_chaining.rb
More file actions
executable file
·56 lines (47 loc) · 1.62 KB
/
execution_plan_chaining.rb
File metadata and controls
executable file
·56 lines (47 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative 'example_helper'
class DelayedAction < Dynflow::Action
def plan(should_fail = false)
plan_self :should_fail => should_fail
end
def run
sleep 5
raise "Controlled failure" if input[:should_fail]
end
def rescue_strategy
Dynflow::Action::Rescue::Fail
end
end
if $PROGRAM_NAME == __FILE__
world = ExampleHelper.create_world do |config|
config.auto_rescue = true
end
world.action_logger.level = 1
world.logger.level = 0
plan1 = world.trigger(DelayedAction)
plan2 = world.chain(plan1.execution_plan_id, DelayedAction)
plan3 = world.chain(plan2.execution_plan_id, DelayedAction)
plan4 = world.chain(plan2.execution_plan_id, DelayedAction)
plan5 = world.trigger(DelayedAction, true)
plan6 = world.chain(plan5.execution_plan_id, DelayedAction)
puts <<-MSG.gsub(/^.*\|/, '')
|
| Execution Plan Chaining example
| ========================
|
| This example shows the execution plan chaining functionality of Dynflow, which allows execution plans to wait until another execution plan finishes.
|
| Execution plans:
| #{plan1.id} runs immediately and should run successfully.
| #{plan2.id} is delayed and should run once #{plan1.id} finishes.
| #{plan3.id} and #{plan4.id} are delayed and should run once #{plan2.id} finishes.
|
| #{plan5.id} runs immediately and is expected to fail.
| #{plan6.id} should not run at all as its prerequisite failed.
|
| Visit #{ExampleHelper::DYNFLOW_URL} to see their status.
|
MSG
ExampleHelper.run_web_console(world)
end