simpler_workflow 0.1.3 → 0.1.4
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/.rspec +2 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/README.md +2 -0
- data/Rakefile +6 -0
- data/ext/mkrf_conf.rb +27 -0
- data/lib/simpler_workflow.rb +1 -0
- data/lib/simpler_workflow/activity.rb +9 -0
- data/lib/simpler_workflow/domain.rb +5 -5
- data/lib/simpler_workflow/version.rb +1 -1
- data/lib/simpler_workflow/workflow.rb +5 -0
- data/simpler_workflow.gemspec +1 -0
- data/spec/domain_spec.rb +130 -0
- data/spec/simpler_workflow_spec.rb +60 -0
- data/spec/spec_helper.rb +24 -0
- metadata +43 -21
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# SimplerWorkflow
|
2
2
|
|
3
|
+
[](http://travis-ci.org/SnuggHome/simpler_workflow)
|
4
|
+
|
3
5
|
A wrapper around Amazon's Simple Workflow Service meant to simplify declaring and using activities and workflow. Provides some sane defaults
|
4
6
|
and work around some idiosyncracies of the platform.
|
5
7
|
|
data/Rakefile
CHANGED
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/command.rb'
|
3
|
+
require 'rubygems/dependency_installer.rb'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Gem::Command.build_args = ARGV
|
7
|
+
rescue NoMethodError
|
8
|
+
end
|
9
|
+
|
10
|
+
inst = Gem::DependencyInstaller.new
|
11
|
+
begin
|
12
|
+
if RUBY_VERSION < "1.9"
|
13
|
+
inst.install "ruby-debug", "~> 0.10.3"
|
14
|
+
else
|
15
|
+
inst.install "ruby-debug19", "~> 0.11.24"
|
16
|
+
end
|
17
|
+
|
18
|
+
if RUBY_PLATFORM =~ /java/i
|
19
|
+
inst.install "jruby-openssl"
|
20
|
+
end
|
21
|
+
rescue
|
22
|
+
exit(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
|
26
|
+
f.write("task :default\n")
|
27
|
+
f.closeeset
|
data/lib/simpler_workflow.rb
CHANGED
@@ -92,6 +92,15 @@ module SimplerWorkflow
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
|
+
|
96
|
+
def poll_for_single_task
|
97
|
+
logger.info("Polling for single task for #{name}")
|
98
|
+
domain.activity_tasks.poll_for_single_task(name.to_s)
|
99
|
+
end
|
100
|
+
|
101
|
+
def count
|
102
|
+
domain.activity_tasks.count(name).to_i
|
103
|
+
end
|
95
104
|
|
96
105
|
def self.[](name, version = nil)
|
97
106
|
case name
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module SimplerWorkflow
|
2
2
|
class Domain
|
3
|
-
def initialize(domain_name,
|
3
|
+
def initialize(domain_name, retention_period = 2, &block)
|
4
4
|
domain_name = domain_name.to_s
|
5
5
|
@domain = swf.domains[domain_name]
|
6
|
-
unless
|
7
|
-
@domain = swf.domains.create(domain_name,
|
6
|
+
unless @domain.exists?
|
7
|
+
@domain = swf.domains.create(domain_name, retention_period) rescue @domain
|
8
8
|
end
|
9
9
|
|
10
10
|
self.instance_eval(&block) if block_given?
|
11
11
|
end
|
12
12
|
|
13
|
-
def Domain.domains(domain_name, &block)
|
13
|
+
def Domain.domains(domain_name, retention_period = 2, &block)
|
14
14
|
@domains ||= {}
|
15
|
-
@domains[domain_name] ||= Domain.new(domain_name)
|
15
|
+
@domains[domain_name] ||= Domain.new(domain_name, retention_period)
|
16
16
|
@domains[domain_name].instance_eval(&block) if block_given?
|
17
17
|
@domains[domain_name]
|
18
18
|
end
|
@@ -161,6 +161,7 @@ module SimplerWorkflow
|
|
161
161
|
def scheduled_event(decision_task, event)
|
162
162
|
decision_task.events.to_a[event.attributes.scheduled_event_id - 1]
|
163
163
|
end
|
164
|
+
|
164
165
|
def last_activity(decision_task, event)
|
165
166
|
scheduled_event(decision_task, event).attributes.activity_type
|
166
167
|
end
|
@@ -168,5 +169,9 @@ module SimplerWorkflow
|
|
168
169
|
def last_input(decision_task, event)
|
169
170
|
scheduled_event(decision_task, event).attributes.input
|
170
171
|
end
|
172
|
+
|
173
|
+
def logger
|
174
|
+
$logger || Rails.logger
|
175
|
+
end
|
171
176
|
end
|
172
177
|
end
|
data/simpler_workflow.gemspec
CHANGED
data/spec/domain_spec.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SimplerWorkflow
|
4
|
+
describe Domain do
|
5
|
+
let(:client) { AWS.config.simple_workflow_client }
|
6
|
+
|
7
|
+
let(:describe_domain_response) { client.stub_for(:describe_domain) }
|
8
|
+
let(:list_domains_response) { client.stub_for(:list_domains) }
|
9
|
+
|
10
|
+
let(:domain) { SimplerWorkflow.domain("test-domain") }
|
11
|
+
|
12
|
+
let(:domain_desc) {{
|
13
|
+
'configuration' => { 'workflowExecutionRetentionPeriodInDays' => '2' },
|
14
|
+
'domainInfo' => {
|
15
|
+
'name' => domain.name,
|
16
|
+
'description' => 'desc',
|
17
|
+
'status' => 'REGISTERED',
|
18
|
+
},
|
19
|
+
}}
|
20
|
+
|
21
|
+
let(:domains_desc) {
|
22
|
+
{
|
23
|
+
'domainInfos' => [
|
24
|
+
domain_desc['domainInfo']
|
25
|
+
]
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
before :each do
|
30
|
+
describe_domain_response.stub(:data).and_return(domain_desc)
|
31
|
+
client.stub(:describe_domain).and_return(describe_domain_response)
|
32
|
+
list_domains_response.stub(:data).and_return(domains_desc)
|
33
|
+
client.stub(:list_domains).and_return(list_domains_response)
|
34
|
+
end
|
35
|
+
|
36
|
+
context "Getting a handle to the domain without a block" do
|
37
|
+
let(:domain_desc) {{
|
38
|
+
'configuration' => { 'workflowExecutionRetentionPeriodInDays' => '2' },
|
39
|
+
'domainInfo' => {
|
40
|
+
'name' => domain.name,
|
41
|
+
'description' => 'desc',
|
42
|
+
'status' => 'REGISTERED',
|
43
|
+
},
|
44
|
+
}}
|
45
|
+
|
46
|
+
let(:domain) { SimplerWorkflow::Domain.domains('test-domain')}
|
47
|
+
|
48
|
+
it "should provide a handle to a domain" do
|
49
|
+
domain.should be_a SimplerWorkflow::Domain
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should provide the name" do
|
53
|
+
domain.name.should == 'test-domain'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should have the default retention period" do
|
57
|
+
domain.retention_period.should == 2
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "Getting a handle to the domain with a custom retention period without a block" do
|
62
|
+
let(:domain_desc) {{
|
63
|
+
'configuration' => { 'workflowExecutionRetentionPeriodInDays' => '14' },
|
64
|
+
'domainInfo' => {
|
65
|
+
'name' => domain.name,
|
66
|
+
'description' => 'desc',
|
67
|
+
'status' => 'REGISTERED',
|
68
|
+
},
|
69
|
+
}}
|
70
|
+
|
71
|
+
let(:domain) { SimplerWorkflow::Domain.domains('test-domain-14', 14)}
|
72
|
+
|
73
|
+
it "should provide the domain name" do
|
74
|
+
domain.name.should == 'test-domain-14'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should provide the specified retention period" do
|
78
|
+
domain.retention_period.should == 14
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "Getting a handle to the domain via the index operator" do
|
83
|
+
let(:domain) { SimplerWorkflow::Domain['test-domain-17']}
|
84
|
+
let(:domain_desc) {{
|
85
|
+
'configuration' => { 'workflowExecutionRetentionPeriodInDays' => '2' },
|
86
|
+
'domainInfo' => {
|
87
|
+
'name' => domain.name,
|
88
|
+
'description' => 'desc',
|
89
|
+
'status' => 'REGISTERED',
|
90
|
+
},
|
91
|
+
}}
|
92
|
+
|
93
|
+
it "should provide the name of the domain" do
|
94
|
+
domain.name.should == 'test-domain-17'
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should provide the default retention period" do
|
98
|
+
domain.retention_period.should == 2
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "Creating a new domain" do
|
103
|
+
it "should create a new domain with the default retention period." do
|
104
|
+
client.should_receive(:describe_domain).
|
105
|
+
with(:name => 'test-domain-15').
|
106
|
+
and_raise(AWS::SimpleWorkflow::Errors::UnknownResourceFault)
|
107
|
+
|
108
|
+
client.should_receive(:register_domain).with(
|
109
|
+
:name => 'test-domain-15', :workflow_execution_retention_period_in_days => '2')
|
110
|
+
|
111
|
+
domain = SimplerWorkflow::Domain.domains('test-domain-15')
|
112
|
+
domain.name.should == 'test-domain-15'
|
113
|
+
domain.retention_period.should == 2
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should create a new domain with the specified retention period" do
|
117
|
+
client.should_receive(:describe_domain).
|
118
|
+
with(:name => 'test-domain-16').
|
119
|
+
and_raise(AWS::SimpleWorkflow::Errors::UnknownResourceFault)
|
120
|
+
|
121
|
+
client.should_receive(:register_domain).with(
|
122
|
+
:name => 'test-domain-16', :workflow_execution_retention_period_in_days => '7')
|
123
|
+
|
124
|
+
domain = SimplerWorkflow::Domain.domains('test-domain-16', 7)
|
125
|
+
domain.name.should == 'test-domain-16'
|
126
|
+
domain.retention_period.should == 7
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SimplerWorkflow do
|
4
|
+
let(:client) { AWS.config.simple_workflow_client }
|
5
|
+
|
6
|
+
let(:describe_domain_response) { client.stub_for(:describe_domain) }
|
7
|
+
let(:list_domains_response) { client.stub_for(:list_domains) }
|
8
|
+
|
9
|
+
let(:domain) { SimplerWorkflow.domain("test-domain") }
|
10
|
+
|
11
|
+
let(:domain_desc) {{
|
12
|
+
'configuration' => { 'workflowExecutionRetentionPeriodInDays' => '2' },
|
13
|
+
'domainInfo' => {
|
14
|
+
'name' => domain.name,
|
15
|
+
'description' => 'desc',
|
16
|
+
'status' => 'REGISTERED',
|
17
|
+
},
|
18
|
+
}}
|
19
|
+
|
20
|
+
let(:domains_desc) {
|
21
|
+
{
|
22
|
+
'domainInfos' => [
|
23
|
+
domain_desc['domainInfo']
|
24
|
+
]
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
context "Referring to a domain" do
|
29
|
+
before :each do
|
30
|
+
describe_domain_response.stub(:data).and_return(domain_desc)
|
31
|
+
client.stub(:describe_domain).and_return(describe_domain_response)
|
32
|
+
list_domains_response.stub(:data).and_return(domains_desc)
|
33
|
+
client.stub(:list_domains).and_return(list_domains_response)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return the domain for the test" do
|
37
|
+
domain.should_not be_nil
|
38
|
+
domain.should be_a(SimplerWorkflow::Domain)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should provide the domain name" do
|
42
|
+
domain.name.should == "test-domain"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should show the default retention period" do
|
46
|
+
domain.retention_period.should == 2
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "getting a handle to the SimpleWorkflow API" do
|
51
|
+
let(:swf) { SimplerWorkflow.swf }
|
52
|
+
it "should return the SWF handle" do
|
53
|
+
swf.should be_a AWS::SimpleWorkflow
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should have the same configuration as AWS" do
|
57
|
+
swf.config.should == AWS.config
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'simpler_workflow'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
15
|
+
|
16
|
+
config.before :each do
|
17
|
+
AWS.stub!
|
18
|
+
AWS.config(:access_key_id => 'TESTKEY', :secret_access_key => 'TESTSECRET')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def stub_list_domains
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simpler_workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Frederic Jean
|
@@ -15,10 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05
|
18
|
+
date: 2012-07-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
name: aws-sdk
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
24
|
none: false
|
23
25
|
requirements:
|
24
26
|
- - ~>
|
@@ -29,12 +31,12 @@ dependencies:
|
|
29
31
|
- 5
|
30
32
|
- 0
|
31
33
|
version: 1.5.0
|
32
|
-
name: aws-sdk
|
33
34
|
type: :runtime
|
34
|
-
|
35
|
-
requirement: *id001
|
35
|
+
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
37
|
+
name: map
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
40
42
|
- - ">="
|
@@ -43,12 +45,12 @@ dependencies:
|
|
43
45
|
segments:
|
44
46
|
- 0
|
45
47
|
version: "0"
|
46
|
-
name: map
|
47
48
|
type: :runtime
|
48
|
-
|
49
|
-
requirement: *id002
|
49
|
+
version_requirements: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
-
|
51
|
+
name: rake
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
54
|
none: false
|
53
55
|
requirements:
|
54
56
|
- - ">="
|
@@ -57,12 +59,12 @@ dependencies:
|
|
57
59
|
segments:
|
58
60
|
- 0
|
59
61
|
version: "0"
|
60
|
-
name: rake
|
61
62
|
type: :development
|
62
|
-
|
63
|
-
requirement: *id003
|
63
|
+
version_requirements: *id003
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
-
|
65
|
+
name: rspec
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
68
|
none: false
|
67
69
|
requirements:
|
68
70
|
- - ">="
|
@@ -71,10 +73,22 @@ dependencies:
|
|
71
73
|
segments:
|
72
74
|
- 0
|
73
75
|
version: "0"
|
74
|
-
name: rspec
|
75
76
|
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: travis-lint
|
76
80
|
prerelease: false
|
77
|
-
requirement:
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id005
|
78
92
|
description: A wrapper around Amazon's Simple Workflow Service
|
79
93
|
email:
|
80
94
|
- fred@snugghome.com
|
@@ -86,10 +100,13 @@ extra_rdoc_files: []
|
|
86
100
|
|
87
101
|
files:
|
88
102
|
- .gitignore
|
103
|
+
- .rspec
|
104
|
+
- .travis.yml
|
89
105
|
- Gemfile
|
90
106
|
- LICENSE
|
91
107
|
- README.md
|
92
108
|
- Rakefile
|
109
|
+
- ext/mkrf_conf.rb
|
93
110
|
- lib/simpler_workflow.rb
|
94
111
|
- lib/simpler_workflow/activity.rb
|
95
112
|
- lib/simpler_workflow/domain.rb
|
@@ -97,6 +114,9 @@ files:
|
|
97
114
|
- lib/simpler_workflow/workflow.rb
|
98
115
|
- lib/simpler_workflow/workflow_collection.rb
|
99
116
|
- simpler_workflow.gemspec
|
117
|
+
- spec/domain_spec.rb
|
118
|
+
- spec/simpler_workflow_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
100
120
|
homepage: https://github.com/SnuggHome/simpler_workflow
|
101
121
|
licenses: []
|
102
122
|
|
@@ -130,5 +150,7 @@ rubygems_version: 1.8.20
|
|
130
150
|
signing_key:
|
131
151
|
specification_version: 3
|
132
152
|
summary: A wrapper and DSL around Amazon's Simple Workflow Service with the goal of making it almost pleasant to define workflows.
|
133
|
-
test_files:
|
134
|
-
|
153
|
+
test_files:
|
154
|
+
- spec/domain_spec.rb
|
155
|
+
- spec/simpler_workflow_spec.rb
|
156
|
+
- spec/spec_helper.rb
|