ntswf 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ntswf/activity_worker.rb +3 -1
- data/lib/ntswf/decision_worker.rb +16 -8
- metadata +2 -2
@@ -21,8 +21,10 @@ module Ntswf
|
|
21
21
|
# Processing result. The following keys are interpreted accordingly:
|
22
22
|
# :error:: Fails the task with the given error details.
|
23
23
|
# :outcome:: Completes the task, storing the outcome's value (as JSON).
|
24
|
+
# :seconds_until_restart::
|
25
|
+
# Starts the task as new, after the given delay.
|
24
26
|
# :seconds_until_retry::
|
25
|
-
# Re-schedules the task after the given delay.
|
27
|
+
# Re-schedules the task, after the given delay.
|
26
28
|
# In combination with an *:error*: Marks the task for immediate re-scheduling,
|
27
29
|
# ignoring the value.
|
28
30
|
# Please note that the behaviour is undefined if an *:interval* option has been set.
|
@@ -36,7 +36,7 @@ module Ntswf
|
|
36
36
|
log("processing event #{event.inspect}")
|
37
37
|
case event.event_type
|
38
38
|
when 'WorkflowExecutionStarted' then schedule(task, event)
|
39
|
-
when 'TimerFired' then retry_or_continue_as_new(task,
|
39
|
+
when 'TimerFired' then retry_or_continue_as_new(task, event)
|
40
40
|
when 'ActivityTaskCompleted' then activity_task_completed(task, event)
|
41
41
|
when 'ActivityTaskFailed' then activity_task_failed(task, event)
|
42
42
|
when 'ActivityTaskTimedOut' then activity_task_timed_out(task, event)
|
@@ -45,8 +45,7 @@ module Ntswf
|
|
45
45
|
|
46
46
|
def activity_task_completed(task, event)
|
47
47
|
result = parse_result(event.attributes.result)
|
48
|
-
start_timer(task, result
|
49
|
-
result: event.attributes.result)
|
48
|
+
start_timer(task, result) or task.complete_workflow_execution(result: event.attributes.result)
|
50
49
|
end
|
51
50
|
|
52
51
|
def activity_task_failed(task, event)
|
@@ -64,18 +63,19 @@ module Ntswf
|
|
64
63
|
start_timer(task) or task.cancel_workflow_execution(details: 'activity task timeout')
|
65
64
|
end
|
66
65
|
|
67
|
-
def start_timer(task,
|
66
|
+
def start_timer(task, result = {})
|
67
|
+
interval = result["seconds_until_retry"] || result["seconds_until_restart"]
|
68
68
|
unless interval
|
69
69
|
options = parse_input(task.events.first.attributes.input)
|
70
70
|
interval = options['interval']
|
71
71
|
end
|
72
|
-
task.start_timer(interval.to_i) if interval
|
72
|
+
task.start_timer(interval.to_i, control: result.to_json) if interval
|
73
73
|
interval
|
74
74
|
end
|
75
75
|
|
76
|
-
def retry_or_continue_as_new(task,
|
77
|
-
|
78
|
-
if
|
76
|
+
def retry_or_continue_as_new(task, event)
|
77
|
+
original_event = task.events.first
|
78
|
+
if to_be_continued?(task, event)
|
79
79
|
keys = [
|
80
80
|
:child_policy,
|
81
81
|
:execution_start_to_close_timeout,
|
@@ -118,6 +118,14 @@ module Ntswf
|
|
118
118
|
|
119
119
|
private
|
120
120
|
|
121
|
+
def to_be_continued?(task, event)
|
122
|
+
options = parse_input(task.events.first.attributes.input)
|
123
|
+
return true if options["interval"]
|
124
|
+
started_event = task.events.find { |e| e.event_id == event.attributes.started_event_id }
|
125
|
+
result = parse_result(started_event.attributes.to_h[:control])
|
126
|
+
result["seconds_until_restart"] || result["perform_again"]
|
127
|
+
end
|
128
|
+
|
121
129
|
# transitional, until all apps speak the input options protocol
|
122
130
|
def guess_app_from(data_providing_event)
|
123
131
|
data_providing_event.workflow_execution.workflow_type.name[/\w+/]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntswf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|