saga_orchestrator 0.16 → 0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Readme.md +2 -4
- data/examples/main.rb +2 -2
- data/examples/workflow_models/definitions/test.rb +17 -4
- data/examples/workflow_models/functions/test.rb +7 -0
- data/lib/state_management/sequences.rb +17 -3
- data/lib/state_management/state_engine.rb +2 -1
- data/lib/state_management/states.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660fd655b8b1b5a8c77932879d252099166b8118edac9b19f50666a14f496da4
|
4
|
+
data.tar.gz: 41fd41fb6eb908496a6a83bc43fb3fbb59d242f295a7048db4b7453f3244b242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c29f521041bff7695e481d7e61d065f2a558afa0c3b843f5222a2f48e701163251826d659f0f3e6b146a4b05e172a2781cf62249807140f8c601954da69c793
|
7
|
+
data.tar.gz: 5c464fb477663cd0773f170382d0cef296986e32cf7e473b27e714f56dbd16e0775eebcf232b83e71b68a2c783d745339fb6e097964337c09f495ac220b5201f
|
data/Readme.md
CHANGED
@@ -46,10 +46,9 @@ To build workflows, the first step is to design the workflow. Let us take an exa
|
|
46
46
|

|
47
47
|
|
48
48
|
1. Create a child class inheriting from Saga::StateEngine
|
49
|
-
2. Add a function
|
49
|
+
2. Add a function state_registration within the child class as below to setup all the states as below. Use register_states features to register various states.
|
50
50
|
|
51
|
-
|
52
|
-
def state_registration
|
51
|
+
def state_registration
|
53
52
|
|
54
53
|
register_states do |add_state|
|
55
54
|
|
@@ -104,7 +103,6 @@ def state_registration
|
|
104
103
|
end
|
105
104
|
|
106
105
|
end
|
107
|
-
'''
|
108
106
|
|
109
107
|
### How to define a state
|
110
108
|
|
data/examples/main.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'saga_orchestrator'
|
1
|
+
require '../lib/saga_orchestrator'
|
2
2
|
require_relative 'workflow_models/definitions/test'
|
3
3
|
|
4
|
-
obj = Saga::Orchestrator::new(Workflows::Test,
|
4
|
+
obj = Saga::Orchestrator::new(Workflows::Test, 3000)
|
5
5
|
puts obj.run()
|
6
6
|
puts obj.execution_sequence
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../../lib/saga_orchestrator'
|
2
2
|
require_relative '../processors/test'
|
3
3
|
require_relative '../functions/test'
|
4
4
|
require_relative '../rollback/test'
|
@@ -42,6 +42,14 @@ module Workflows
|
|
42
42
|
state.process_output Processors::Test.method(:processor)
|
43
43
|
end
|
44
44
|
|
45
|
+
add_state.standard :sample4 do |state|
|
46
|
+
state.call Functions::Test.method(:test_func4)
|
47
|
+
state.params do |p|
|
48
|
+
p.set_type :input_params
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
45
53
|
add_state.standard :cond01 do |state|
|
46
54
|
state.call Functions::Test.method(:conditional_test)
|
47
55
|
state.params do |p|
|
@@ -55,14 +63,19 @@ module Workflows
|
|
55
63
|
|
56
64
|
def sequence_states
|
57
65
|
describe_flows do |seqs|
|
66
|
+
|
67
|
+
seqs.sub :seq_b do |seq|
|
68
|
+
seq.init state_name :sample4
|
69
|
+
seq.end
|
70
|
+
end
|
71
|
+
|
58
72
|
seqs.start :seq_a do |seq|
|
59
73
|
seq.init state_name :sample
|
60
74
|
seq.then state_name :sample2
|
61
75
|
seq.then_conditional state_name :cond01 do |t|
|
62
|
-
t.on_true
|
63
|
-
t.on_false state_name :
|
76
|
+
t.on_true sequence_name :seq_b
|
77
|
+
t.on_false state_name :sample3
|
64
78
|
end
|
65
|
-
seq.then state_name :sample3
|
66
79
|
seq.end
|
67
80
|
end
|
68
81
|
end
|
@@ -18,6 +18,13 @@ module Functions
|
|
18
18
|
raise StandardError, "An error occurred"
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.test_func4 input
|
22
|
+
puts "in test_func: input - #{input}"
|
23
|
+
res = input * 10000
|
24
|
+
puts "result = #{res}"
|
25
|
+
res
|
26
|
+
end
|
27
|
+
|
21
28
|
def self.conditional_test input
|
22
29
|
res = input > 0
|
23
30
|
puts "result = #{res}"
|
@@ -21,6 +21,12 @@ module Saga
|
|
21
21
|
@run_state = nil
|
22
22
|
end
|
23
23
|
|
24
|
+
def set_run_status bool
|
25
|
+
if bool.is_a?(TrueClass) || bool.is_a?(FalseClass)
|
26
|
+
@run_state = bool
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
def run params = nil, last_state_result=nil
|
25
31
|
|
26
32
|
if self.type == :stop
|
@@ -44,7 +50,7 @@ module Saga
|
|
44
50
|
def next
|
45
51
|
|
46
52
|
if @run_state.nil?
|
47
|
-
raise NodeNotRunError.new("Node has not been run yet.", { reason: "Next can only be decided after node has been run.", code: 1001 })
|
53
|
+
raise NodeNotRunError.new("Node has not been run yet.: #{self.name}", { reason: "Next can only be decided after node has been run.", code: 1001 })
|
48
54
|
end
|
49
55
|
|
50
56
|
if @run_state == true
|
@@ -61,14 +67,18 @@ module Saga
|
|
61
67
|
def set_do task
|
62
68
|
|
63
69
|
if task.nil?
|
64
|
-
raise NullStateError.new("
|
70
|
+
raise NullStateError.new("Attempt to run an undefined state.", { reason: "State has not been defined or registered.", code: 1001 })
|
65
71
|
end
|
66
72
|
|
67
73
|
if task.is_a?(Sequence)
|
68
74
|
@action_type = :sequence
|
75
|
+
@name = task.name
|
76
|
+
puts "within sequence - #{@name}"
|
77
|
+
else
|
78
|
+
@name = task.state_name
|
79
|
+
puts "within task - #{@name}"
|
69
80
|
end
|
70
81
|
@do = task
|
71
|
-
@name = task.state_name
|
72
82
|
end
|
73
83
|
|
74
84
|
def name
|
@@ -152,6 +162,10 @@ module Saga
|
|
152
162
|
@initial_node = nil
|
153
163
|
end
|
154
164
|
|
165
|
+
def name
|
166
|
+
@name
|
167
|
+
end
|
168
|
+
|
155
169
|
def first
|
156
170
|
@initial_node
|
157
171
|
end
|
@@ -86,8 +86,9 @@ module Saga
|
|
86
86
|
current_node = active_node
|
87
87
|
|
88
88
|
begin
|
89
|
-
if current_node.
|
89
|
+
if current_node.sequence?
|
90
90
|
conduct_sequence current_node.activity.first
|
91
|
+
current_node.set_run_status true
|
91
92
|
else
|
92
93
|
@executing_node = current_node
|
93
94
|
res = current_node.run @params, @last_result
|
@@ -30,7 +30,9 @@ module Saga
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def get_state_by_name name
|
33
|
-
@states[name]
|
33
|
+
res = @states[name]
|
34
|
+
raise NullStateError.new("Attempt to run an undefined state = #{name}.", { reason: "State has not been defined or registered.", code: 1001 }) if res.nil?
|
35
|
+
res
|
34
36
|
end
|
35
37
|
|
36
38
|
def keys
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saga_orchestrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jayanth Ravindran
|
@@ -42,7 +42,8 @@ files:
|
|
42
42
|
homepage: https://rubygems.org/gems/saga_orchestrator
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
|
-
metadata:
|
45
|
+
metadata:
|
46
|
+
source_code_uri: https://github.com/jravz/saga_orchestrator
|
46
47
|
post_install_message:
|
47
48
|
rdoc_options: []
|
48
49
|
require_paths:
|