ntswf 1.0.1 → 1.0.3
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/README.md +1 -0
- data/lib/ntswf/base.rb +15 -14
- data/lib/ntswf/decision_worker.rb +2 -2
- data/lib/ntswf/utils.rb +1 -1
- data/lib/ntswf.rb +3 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -8,6 +8,7 @@ AWS Simple Workflow.
|
|
8
8
|
|
9
9
|
[](http://badge.fury.io/rb/ntswf)
|
10
10
|
[](https://codeclimate.com/github/infopark/ntswf)
|
11
|
+
[](https://gemnasium.com/infopark/ntswf)
|
11
12
|
|
12
13
|
Usage
|
13
14
|
-----
|
data/lib/ntswf/base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'aws'
|
2
|
+
require 'ostruct'
|
2
3
|
|
3
4
|
module Ntswf
|
4
5
|
module Base
|
@@ -11,14 +12,14 @@ module Ntswf
|
|
11
12
|
# @option config [String] :secret_access_key AWS credential
|
12
13
|
# @option config [String] :unit This worker/client's activity task list key
|
13
14
|
def initialize(config)
|
14
|
-
@config = config
|
15
|
+
@config = OpenStruct.new(config)
|
15
16
|
raise_if_invalid_task_list
|
16
17
|
end
|
17
18
|
|
18
19
|
# @return [AWS::SimpleWorkflow]
|
19
20
|
def swf
|
20
|
-
@swf ||= AWS::SimpleWorkflow.new(@config.
|
21
|
-
use_ssl: true)
|
21
|
+
@swf ||= AWS::SimpleWorkflow.new(access_key_id: @config.access_key_id,
|
22
|
+
secret_access_key: @config.secret_access_key, use_ssl: true)
|
22
23
|
end
|
23
24
|
|
24
25
|
def workflow_name
|
@@ -30,38 +31,38 @@ module Ntswf
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def domain
|
33
|
-
@domain ||= swf.domains[@config
|
34
|
+
@domain ||= swf.domains[@config.domain]
|
34
35
|
end
|
35
36
|
|
36
37
|
def activity_task_lists
|
37
|
-
@config
|
38
|
+
@config.activity_task_lists
|
38
39
|
end
|
39
40
|
|
40
41
|
def decision_task_list
|
41
|
-
@config
|
42
|
+
@config.decision_task_list or raise "Missing decision task list configuration"
|
42
43
|
end
|
43
44
|
|
44
45
|
def activity_task_list
|
45
|
-
activity_task_lists[default_unit]
|
46
|
+
activity_task_lists[default_unit] or raise "Missing activity task list configuration"
|
46
47
|
end
|
47
48
|
|
48
49
|
def default_unit
|
49
|
-
@default_unit ||= @config
|
50
|
+
@default_unit ||= @config.unit.to_s
|
50
51
|
end
|
51
52
|
|
52
53
|
def execution_version
|
53
|
-
@config
|
54
|
+
@config.execution_version
|
54
55
|
end
|
55
56
|
|
56
57
|
# Parse the options stored in a task's *input* value
|
57
58
|
# @param input [String] A task's input
|
58
|
-
# @return [Hash]
|
59
|
+
# @return [Hash] Input, converted back from JSON
|
59
60
|
# @see Ntswf::Client#start_execution Hash keys to be expected
|
60
61
|
def parse_input(input)
|
61
62
|
options, legacy_params = JSON.parse(input)
|
62
|
-
options = {name
|
63
|
-
options.merge!(params
|
64
|
-
options
|
63
|
+
options = {"name" => options} unless options.kind_of? Hash
|
64
|
+
options.merge!("params" => legacy_params) if legacy_params
|
65
|
+
options
|
65
66
|
end
|
66
67
|
|
67
68
|
def notify(message, params)
|
@@ -80,7 +81,7 @@ module Ntswf
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def raise_if_invalid_task_list
|
83
|
-
|
84
|
+
[*activity_task_lists.values, decision_task_list].each do |task_list|
|
84
85
|
if task_list.include?(separator)
|
85
86
|
raise "Invalid config '#{task_list}': Separator '#{separator}' is reserved for internal use."
|
86
87
|
end
|
@@ -46,7 +46,7 @@ module Ntswf
|
|
46
46
|
task.continue_as_new_workflow_execution(attributes)
|
47
47
|
when 'ActivityTaskCompleted'
|
48
48
|
result = parse_result(event.attributes.result)
|
49
|
-
start_timer(task, result[
|
49
|
+
start_timer(task, result["seconds_until_retry"]) or task.complete_workflow_execution(
|
50
50
|
result: event.attributes.result)
|
51
51
|
when 'ActivityTaskFailed'
|
52
52
|
if (event.attributes.reason == RETRY)
|
@@ -94,7 +94,7 @@ module Ntswf
|
|
94
94
|
value = JSON.parse(result) rescue nil # expecting JSON::ParserError
|
95
95
|
end
|
96
96
|
value = {} unless value.kind_of? Hash
|
97
|
-
value
|
97
|
+
value
|
98
98
|
end
|
99
99
|
|
100
100
|
private
|
data/lib/ntswf/utils.rb
CHANGED
data/lib/ntswf.rb
CHANGED
@@ -9,6 +9,8 @@ module Ntswf
|
|
9
9
|
AUTOLOAD.each { |c| autoload c.to_sym, "ntswf/#{c.gsub(/.(?=[A-Z])/, '\0_').downcase}.rb" }
|
10
10
|
|
11
11
|
def self.included(base)
|
12
|
-
|
12
|
+
base.module_exec do
|
13
|
+
AUTOLOAD.each { |c| include const_get c }
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.3
|
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-01-
|
12
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -35,13 +35,13 @@ extra_rdoc_files: []
|
|
35
35
|
files:
|
36
36
|
- README.md
|
37
37
|
- LICENSE
|
38
|
-
- lib/ntswf.rb
|
39
|
-
- lib/ntswf/base.rb
|
38
|
+
- lib/ntswf/decision_worker.rb
|
40
39
|
- lib/ntswf/utils.rb
|
41
|
-
- lib/ntswf/client.rb
|
42
|
-
- lib/ntswf/worker.rb
|
43
40
|
- lib/ntswf/activity_worker.rb
|
44
|
-
- lib/ntswf/
|
41
|
+
- lib/ntswf/worker.rb
|
42
|
+
- lib/ntswf/client.rb
|
43
|
+
- lib/ntswf/base.rb
|
44
|
+
- lib/ntswf.rb
|
45
45
|
homepage: https://github.com/infopark/ntswf
|
46
46
|
licenses:
|
47
47
|
- LGPLv3
|