ntswf 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ntswf/activity_worker.rb +8 -1
- data/lib/ntswf/decision_worker.rb +26 -20
- metadata +2 -2
@@ -11,7 +11,9 @@ module Ntswf
|
|
11
11
|
# :activity_task:: The {AWS::SimpleWorkflow::ActivityTask}
|
12
12
|
# :name:: Kind of task
|
13
13
|
# :params:: Custom parameters given to the execution (parsed back from JSON)
|
14
|
+
# :run_id:: The workflow execution's run ID
|
14
15
|
# :version:: Client version
|
16
|
+
# :workflow_id:: The workflow execution's workflow ID
|
15
17
|
#
|
16
18
|
# See {Ntswf::Client#start_execution}'s options for details
|
17
19
|
# @param proc [Proc] The callback
|
@@ -54,7 +56,12 @@ module Ntswf
|
|
54
56
|
protected
|
55
57
|
|
56
58
|
def describe(activity_task)
|
57
|
-
options = parse_input(activity_task.input)
|
59
|
+
options = parse_input(activity_task.input)
|
60
|
+
options.merge!(
|
61
|
+
activity_task: activity_task,
|
62
|
+
run_id: activity_task.workflow_execution.run_id,
|
63
|
+
workflow_id: activity_task.workflow_execution.workflow_id,
|
64
|
+
)
|
58
65
|
options.map { |k, v| {k.to_sym => v} }.reduce(&:merge!)
|
59
66
|
end
|
60
67
|
|
@@ -35,29 +35,35 @@ module Ntswf
|
|
35
35
|
def process_decision_event(task, event)
|
36
36
|
log("processing event #{event.inspect}")
|
37
37
|
case event.event_type
|
38
|
-
when 'WorkflowExecutionStarted'
|
39
|
-
|
40
|
-
when '
|
41
|
-
|
42
|
-
when '
|
43
|
-
result = parse_result(event.attributes.result)
|
44
|
-
start_timer(task, result["seconds_until_retry"]) or task.complete_workflow_execution(
|
45
|
-
result: event.attributes.result)
|
46
|
-
when 'ActivityTaskFailed'
|
47
|
-
if (event.attributes.reason == RETRY)
|
48
|
-
schedule(task, task.events.first)
|
49
|
-
else
|
50
|
-
start_timer(task) or task.fail_workflow_execution(
|
51
|
-
event.attributes.to_h.keep_if {|k| [:details, :reason].include? k})
|
52
|
-
end
|
53
|
-
when 'ActivityTaskTimedOut'
|
54
|
-
notify("Timeout in Simple Workflow. Possible cause: all workers busy",
|
55
|
-
workflow_execution: task.workflow_execution.inspect)
|
56
|
-
start_timer(task) or task.cancel_workflow_execution(
|
57
|
-
details: 'activity task timeout')
|
38
|
+
when 'WorkflowExecutionStarted' then schedule(task, event)
|
39
|
+
when 'TimerFired' then retry_or_continue_as_new(task, task.events.first)
|
40
|
+
when 'ActivityTaskCompleted' then activity_task_completed(task, event)
|
41
|
+
when 'ActivityTaskFailed' then activity_task_failed(task, event)
|
42
|
+
when 'ActivityTaskTimedOut' then activity_task_timed_out(task, event)
|
58
43
|
end
|
59
44
|
end
|
60
45
|
|
46
|
+
def activity_task_completed(task, event)
|
47
|
+
result = parse_result(event.attributes.result)
|
48
|
+
start_timer(task, result["seconds_until_retry"]) or task.complete_workflow_execution(
|
49
|
+
result: event.attributes.result)
|
50
|
+
end
|
51
|
+
|
52
|
+
def activity_task_failed(task, event)
|
53
|
+
if (event.attributes.reason == RETRY)
|
54
|
+
schedule(task, task.events.first)
|
55
|
+
else
|
56
|
+
start_timer(task) or task.fail_workflow_execution(
|
57
|
+
event.attributes.to_h.keep_if {|k| [:details, :reason].include? k})
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def activity_task_timed_out(task, event)
|
62
|
+
notify("Timeout in Simple Workflow. Possible cause: all workers busy",
|
63
|
+
workflow_execution: task.workflow_execution.inspect)
|
64
|
+
start_timer(task) or task.cancel_workflow_execution(details: 'activity task timeout')
|
65
|
+
end
|
66
|
+
|
61
67
|
def start_timer(task, interval = nil)
|
62
68
|
unless interval
|
63
69
|
options = parse_input(task.events.first.attributes.input)
|
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.2
|
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-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|