libis-workflow 2.0.33 → 2.0.34
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/lib/libis/workflow/base/logging.rb +1 -0
- data/lib/libis/workflow/base/work_item.rb +5 -13
- data/lib/libis/workflow/base/workflow.rb +1 -0
- data/lib/libis/workflow/task.rb +28 -20
- data/lib/libis/workflow/version.rb +1 -1
- data/lib/libis/workflow/work_item.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb823bd0608daf4a967030f006907ea878a2f76b
|
4
|
+
data.tar.gz: ce590a7b9e6ad276081218e2c49af9742df33a11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c999e3ff98da80b45e4709d789a4f1e15f54d39906ff025f8016b52c3573dd08eab94f2769fd36f655b0f60a7adfb3dd2a9e2fc5634fd8c02ae9a7bbfd1e52f2
|
7
|
+
data.tar.gz: 2a08d0d8d62e5c26bbb07540174ffd3d6ddefa3fd90d2c034ab47c6a68d3ede00c3c3a64e56ad9c526038ef0b54fd2b7b2e81258143dd18c5698418445e4ff00
|
@@ -53,6 +53,8 @@ module Libis
|
|
53
53
|
# self.status_log << info
|
54
54
|
# end
|
55
55
|
#
|
56
|
+
# The implementation should also take care that the public methods #save and #save! are implemented.
|
57
|
+
# ActiveRecord and Mongoid are known to implement these, but others may not.
|
56
58
|
#
|
57
59
|
module WorkItem
|
58
60
|
include Enumerable
|
@@ -133,7 +135,9 @@ module Libis
|
|
133
135
|
return self unless item and item.is_a?(Libis::Workflow::Base::WorkItem)
|
134
136
|
self.items << item
|
135
137
|
item.parent = self
|
138
|
+
# noinspection RubyResolve
|
136
139
|
self.save!
|
140
|
+
# noinspection RubyResolve
|
137
141
|
item.save!
|
138
142
|
self
|
139
143
|
end
|
@@ -172,19 +176,7 @@ module Libis
|
|
172
176
|
# @return [Libis::Workflow::Base::Run]
|
173
177
|
def get_run
|
174
178
|
return self if self.is_a?(Libis::Workflow::Base::Run)
|
175
|
-
self.get_parent
|
176
|
-
end
|
177
|
-
|
178
|
-
# Dummy method. It is a placeholder for DB backed implementations. Wherever appropriate WorkItem#save will be
|
179
|
-
# called to save the current item's state. If state needs to persisted, you should override this method or make
|
180
|
-
# sure your persistence layer implements it in your class.
|
181
|
-
def save
|
182
|
-
end
|
183
|
-
|
184
|
-
# Dummy method. It is a placeholder for DB backed implementations. Wherever appropriate WorkItem#save will be
|
185
|
-
# called to save the current item's state. If state needs to persisted, you should override this method or make
|
186
|
-
# sure your persistence layer implements it in your class.
|
187
|
-
def save!
|
179
|
+
self.get_parent&.get_run
|
188
180
|
end
|
189
181
|
|
190
182
|
end
|
data/lib/libis/workflow/task.rb
CHANGED
@@ -23,7 +23,9 @@ module Libis
|
|
23
23
|
parameter retry_interval: 10, description: 'Number of seconds to wait between retries.'
|
24
24
|
|
25
25
|
def self.task_classes
|
26
|
-
|
26
|
+
# noinspection RubyArgCount
|
27
|
+
ObjectSpace.each_object(::Class)
|
28
|
+
.select {|klass| klass < self && klass != Libis::Workflow::TaskRunner}
|
27
29
|
end
|
28
30
|
|
29
31
|
def initialize(parent, cfg = {})
|
@@ -43,15 +45,15 @@ module Libis
|
|
43
45
|
self.workitem = item
|
44
46
|
|
45
47
|
case action
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
return item
|
50
|
-
end
|
51
|
-
when :failed
|
48
|
+
when :retry
|
49
|
+
if item.check_status(:DONE, namepath)
|
50
|
+
debug 'Retry: skipping task %s because it has finished successfully.', item, namepath
|
52
51
|
return item
|
53
|
-
|
54
|
-
|
52
|
+
end
|
53
|
+
when :failed
|
54
|
+
return item
|
55
|
+
else
|
56
|
+
# type code here
|
55
57
|
end
|
56
58
|
|
57
59
|
(parameter(:retry_count) + 1).times do
|
@@ -59,18 +61,19 @@ module Libis
|
|
59
61
|
i = run_item(item)
|
60
62
|
item = i if i.is_a?(Libis::Workflow::WorkItem)
|
61
63
|
|
64
|
+
# noinspection RubyScope
|
62
65
|
case item.status(namepath)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
when :DONE
|
67
|
+
self.action = :run
|
68
|
+
return item
|
69
|
+
when :ASYNC_WAIT
|
70
|
+
self.action = :retry
|
71
|
+
when :ASYNC_HALT
|
72
|
+
break
|
73
|
+
when :FAILED
|
74
|
+
break
|
75
|
+
else
|
76
|
+
return item
|
74
77
|
end
|
75
78
|
|
76
79
|
self.action = :retry
|
@@ -201,9 +204,11 @@ module Libis
|
|
201
204
|
|
202
205
|
rescue Libis::WorkflowError => e
|
203
206
|
item.set_status(namepath, :FAILED)
|
207
|
+
error 'Error processing subitem (%d/%d): %s', item, i + 1, items.size, e.message
|
204
208
|
break if parameter(:abort_recursion_on_failure)
|
205
209
|
|
206
210
|
rescue Libis::WorkflowAbort => e
|
211
|
+
fatal_error 'Fatal error processing subitem (%d/%d): %s', item, i + 1, items.size, e.message
|
207
212
|
item.set_status(namepath, :FAILED)
|
208
213
|
break
|
209
214
|
|
@@ -216,7 +221,9 @@ module Libis
|
|
216
221
|
parent_item.status_progress(namepath, i + 1)
|
217
222
|
|
218
223
|
ensure
|
224
|
+
# noinspection RubyScope
|
219
225
|
item_status = item.status(namepath)
|
226
|
+
# noinspection RubyScope
|
220
227
|
status_count[item_status] += 1
|
221
228
|
break if parameter(:abort_recursion_on_failure) && item_status != :DONE
|
222
229
|
|
@@ -224,6 +231,7 @@ module Libis
|
|
224
231
|
|
225
232
|
end
|
226
233
|
|
234
|
+
# noinspection RubyScope
|
227
235
|
debug '%d of %d subitems passed', parent_item, status_count[:DONE], items.size
|
228
236
|
substatus_check(status_count, parent_item, 'item')
|
229
237
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
|
-
VERSION = '2.0.
|
3
|
+
VERSION = '2.0.34' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
4
4
|
end
|
5
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|