ntswf 2.0.0 → 2.0.1
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.
- data/lib/ntswf/base.rb +11 -0
- data/lib/ntswf/client.rb +14 -10
- metadata +1 -1
data/lib/ntswf/base.rb
CHANGED
@@ -18,6 +18,16 @@ module Ntswf
|
|
18
18
|
raise_if_invalid_task_list
|
19
19
|
end
|
20
20
|
|
21
|
+
# Configure a proc or block to be called on handled errors
|
22
|
+
# @yieldparam error [Hash]
|
23
|
+
# Description of the error:
|
24
|
+
# :message:: The error message or the exception
|
25
|
+
# :params:: Error details
|
26
|
+
# @param proc [Proc] The callback
|
27
|
+
def on_notify(proc = nil, &block)
|
28
|
+
@notify_callback = proc || block
|
29
|
+
end
|
30
|
+
|
21
31
|
# @return [AWS::SimpleWorkflow]
|
22
32
|
def swf
|
23
33
|
@swf ||= AWS::SimpleWorkflow.new(access_key_id: @config.access_key_id,
|
@@ -69,6 +79,7 @@ module Ntswf
|
|
69
79
|
|
70
80
|
def notify(message, params)
|
71
81
|
log("#{message.message}\n #{message.backtrace.join("\n ")}") if message.kind_of? Exception
|
82
|
+
@notify_callback.call(message: message, params: params) if @notify_callback
|
72
83
|
end
|
73
84
|
|
74
85
|
# @return [String] separator for composite *workflow_id*
|
data/lib/ntswf/client.rb
CHANGED
@@ -25,16 +25,7 @@ module Ntswf
|
|
25
25
|
# @return (see #find)
|
26
26
|
# @raise [AWS::SimpleWorkflow::Errors::WorkflowExecutionAlreadyStartedFault]
|
27
27
|
def start_execution(options)
|
28
|
-
|
29
|
-
workflow_execution = workflow_type.start_execution(
|
30
|
-
child_policy: :terminate,
|
31
|
-
execution_start_to_close_timeout: 48 * 3600,
|
32
|
-
input: options.to_json,
|
33
|
-
tag_list: [options[:unit].to_s, options[:name].to_s],
|
34
|
-
task_list: decision_task_list,
|
35
|
-
task_start_to_close_timeout: 10 * 60,
|
36
|
-
workflow_id: [activity_task_list, execution_id].join(separator),
|
37
|
-
)
|
28
|
+
workflow_execution = start_swf_workflow_execution(options)
|
38
29
|
execution_details(workflow_execution).merge!(
|
39
30
|
name: options[:name].to_s,
|
40
31
|
params: options[:params],
|
@@ -63,6 +54,19 @@ module Ntswf
|
|
63
54
|
|
64
55
|
protected
|
65
56
|
|
57
|
+
def start_swf_workflow_execution(options)
|
58
|
+
execution_id = options.delete(:execution_id)
|
59
|
+
workflow_type.start_execution(
|
60
|
+
child_policy: :terminate,
|
61
|
+
execution_start_to_close_timeout: 48 * 3600,
|
62
|
+
input: options.to_json,
|
63
|
+
tag_list: [options[:unit].to_s, options[:name].to_s],
|
64
|
+
task_list: decision_task_list,
|
65
|
+
task_start_to_close_timeout: 10 * 60,
|
66
|
+
workflow_id: [activity_task_list, execution_id].join(separator),
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
66
70
|
def execution_details(workflow_execution)
|
67
71
|
{
|
68
72
|
workflow_id: workflow_execution.workflow_id,
|