aws-flow 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/aws-flow.gemspec +4 -2
  2. data/lib/aws-flow.rb +1 -0
  3. data/lib/aws/decider/decider.rb +2 -2
  4. data/lib/aws/decider/workflow_client.rb +1 -0
  5. data/lib/aws/decider/workflow_clock.rb +3 -3
  6. metadata +3 -29
  7. data/aws-flow-core/Gemfile +0 -9
  8. data/aws-flow-core/LICENSE.TXT +0 -15
  9. data/aws-flow-core/NOTICE.TXT +0 -14
  10. data/aws-flow-core/Rakefile +0 -27
  11. data/aws-flow-core/aws-flow-core.gemspec +0 -12
  12. data/aws-flow-core/lib/aws/flow.rb +0 -26
  13. data/aws-flow-core/lib/aws/flow/async_backtrace.rb +0 -134
  14. data/aws-flow-core/lib/aws/flow/async_scope.rb +0 -195
  15. data/aws-flow-core/lib/aws/flow/begin_rescue_ensure.rb +0 -386
  16. data/aws-flow-core/lib/aws/flow/fiber.rb +0 -77
  17. data/aws-flow-core/lib/aws/flow/flow_utils.rb +0 -50
  18. data/aws-flow-core/lib/aws/flow/future.rb +0 -109
  19. data/aws-flow-core/lib/aws/flow/implementation.rb +0 -151
  20. data/aws-flow-core/lib/aws/flow/simple_dfa.rb +0 -85
  21. data/aws-flow-core/lib/aws/flow/tasks.rb +0 -405
  22. data/aws-flow-core/test/aws/async_backtrace_spec.rb +0 -41
  23. data/aws-flow-core/test/aws/async_scope_spec.rb +0 -118
  24. data/aws-flow-core/test/aws/begin_rescue_ensure_spec.rb +0 -665
  25. data/aws-flow-core/test/aws/external_task_spec.rb +0 -197
  26. data/aws-flow-core/test/aws/factories.rb +0 -52
  27. data/aws-flow-core/test/aws/fiber_condition_variable_spec.rb +0 -163
  28. data/aws-flow-core/test/aws/fiber_spec.rb +0 -78
  29. data/aws-flow-core/test/aws/flow_spec.rb +0 -255
  30. data/aws-flow-core/test/aws/future_spec.rb +0 -210
  31. data/aws-flow-core/test/aws/rubyflow.rb +0 -22
  32. data/aws-flow-core/test/aws/simple_dfa_spec.rb +0 -63
  33. data/aws-flow-core/test/aws/spec_helper.rb +0 -36
@@ -1,12 +1,14 @@
1
+ require './lib/aws/decider/version'
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'aws-flow'
3
- s.version = '1.0.0'
5
+ s.version = AWS::Flow::version
4
6
  s.date = Time.now
5
7
  s.summary = "AWS Flow Decider package decider"
6
8
  s.description = "Library to provide the AWS Flow Framework for Ruby"
7
9
  s.authors = "Michael Steger"
8
10
  s.email = ''
9
- s.files = `git ls-files`.split("\n")
11
+ s.files = `git ls-files`.split("\n").reject {|file| file =~ /aws-flow-core/}
10
12
  s.require_paths << "lib/aws/"
11
13
  s.add_dependency "aws-sdk", "~> 1"
12
14
  s.add_dependency "aws-flow-core", "~> 1"
@@ -0,0 +1 @@
1
+ require 'aws/decider'
@@ -450,7 +450,7 @@ module AWS
450
450
  #
451
451
  # @!visibility private
452
452
  def async_create_timer(delay_seconds, &block)
453
- task { self.decision_context.workflow_clock.create_timer(delay_seconds, block) }
453
+ AWS::Flow::Core::task { self.decision_context.workflow_clock.create_timer(delay_seconds, block) }
454
454
  end
455
455
 
456
456
 
@@ -459,7 +459,7 @@ module AWS
459
459
  # @param (see #create_timer)
460
460
  #
461
461
  def create_timer_async(delay_seconds, &block)
462
- task { self.decision_context.workflow_clock.create_timer(delay_seconds, block) }
462
+ AWS::Flow::Core::task { self.decision_context.workflow_clock.create_timer(delay_seconds, block) }
463
463
  end
464
464
 
465
465
 
@@ -331,6 +331,7 @@ module AWS
331
331
 
332
332
 
333
333
  # Instances of WorkflowFactory are generated by {#workflow_factory}.
334
+ # @!visibility private
334
335
  class WorkflowFactory
335
336
 
336
337
 
@@ -75,15 +75,15 @@ module AWS
75
75
  open_request = OpenRequestInfo.new
76
76
  open_request.blocking_promise = Future.new
77
77
  if block
78
- open_request.result = task do
78
+ open_request.result = AWS::Flow::Core::task do
79
79
  open_request.blocking_promise.get
80
80
  block.call
81
81
  end
82
82
  else
83
83
  open_request.result = open_request.blocking_promise
84
84
  end
85
- external_task do |t|
86
- t.initiate_task do |handle|
85
+ external_AWS::Flow::Core::task do |t|
86
+ t.initiate_AWS::Flow::Core::task do |handle|
87
87
  open_request.completion_handle = handle
88
88
  @decision_helper.scheduled_timers[timer_id.to_s] = open_request
89
89
  @decision_helper[timer_id.to_s] = TimerDecisionStateMachine.new(timer_id, attributes)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2013-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -53,34 +53,8 @@ files:
53
53
  - LICENSE.TXT
54
54
  - NOTICE.TXT
55
55
  - Rakefile
56
- - aws-flow-core/Gemfile
57
- - aws-flow-core/LICENSE.TXT
58
- - aws-flow-core/NOTICE.TXT
59
- - aws-flow-core/Rakefile
60
- - aws-flow-core/aws-flow-core.gemspec
61
- - aws-flow-core/lib/aws/flow.rb
62
- - aws-flow-core/lib/aws/flow/async_backtrace.rb
63
- - aws-flow-core/lib/aws/flow/async_scope.rb
64
- - aws-flow-core/lib/aws/flow/begin_rescue_ensure.rb
65
- - aws-flow-core/lib/aws/flow/fiber.rb
66
- - aws-flow-core/lib/aws/flow/flow_utils.rb
67
- - aws-flow-core/lib/aws/flow/future.rb
68
- - aws-flow-core/lib/aws/flow/implementation.rb
69
- - aws-flow-core/lib/aws/flow/simple_dfa.rb
70
- - aws-flow-core/lib/aws/flow/tasks.rb
71
- - aws-flow-core/test/aws/async_backtrace_spec.rb
72
- - aws-flow-core/test/aws/async_scope_spec.rb
73
- - aws-flow-core/test/aws/begin_rescue_ensure_spec.rb
74
- - aws-flow-core/test/aws/external_task_spec.rb
75
- - aws-flow-core/test/aws/factories.rb
76
- - aws-flow-core/test/aws/fiber_condition_variable_spec.rb
77
- - aws-flow-core/test/aws/fiber_spec.rb
78
- - aws-flow-core/test/aws/flow_spec.rb
79
- - aws-flow-core/test/aws/future_spec.rb
80
- - aws-flow-core/test/aws/rubyflow.rb
81
- - aws-flow-core/test/aws/simple_dfa_spec.rb
82
- - aws-flow-core/test/aws/spec_helper.rb
83
56
  - aws-flow.gemspec
57
+ - lib/aws-flow.rb
84
58
  - lib/aws/decider.rb
85
59
  - lib/aws/decider/activity.rb
86
60
  - lib/aws/decider/activity_definition.rb
@@ -1,9 +0,0 @@
1
- source "http://www.rubygems.org"
2
-
3
- gemspec
4
-
5
- group :test do
6
- gem "rspec", "1.3.0"
7
- gem "factory_girl"
8
- gem "rake"
9
- end
@@ -1,15 +0,0 @@
1
- # @markup markdown
2
- # @title AWS Flow Framework for Ruby License
3
-
4
- Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License"). You
7
- may not use this file except in compliance with the License. A copy of
8
- the License is located at:
9
-
10
- * <http://aws.amazon.com/apache2.0/>
11
-
12
- or in the "LICENSE" file accompanying this file. This file is
13
- distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
14
- ANY KIND, either express or implied. See the License for the specific
15
- language governing permissions and limitations under the License.
@@ -1,14 +0,0 @@
1
- AWS Flow for Ruby
2
- Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
-
4
- This product includes software developed by
5
- Amazon Technologies, Inc (http://www.amazon.com/).
6
-
7
- **********************
8
- THIRD PARTY COMPONENTS
9
- **********************
10
- This software includes third party software subject to the following copyrights:
11
- - XML parsing and utility functions from JetS3t - Copyright 2006-2009 James Murty.
12
- - JSON parsing and utility functions from JSON.org - Copyright 2002 JSON.org.
13
-
14
- The licenses for these third party components are included in LICENSE.txt
@@ -1,27 +0,0 @@
1
- ##
2
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/apache2.0
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
14
- ##
15
-
16
- require 'spec/rake/spectask'
17
-
18
- Spec::Rake::SpecTask.new(:spec) do |t|
19
- t.libs << 'lib'
20
- t.spec_opts = ['--color', '--format nested']
21
- t.spec_files = FileList['test/**/*.rb']
22
- t.spec_files.delete_if {|x| x =~ /.*factories.rb/ || x =~ /.*spec_helper.rb/}
23
- t.spec_files.unshift("test/aws/factories.rb")
24
- t.spec_files.unshift("test/aws/spec_helper.rb")
25
- end
26
-
27
- task :test => :spec
@@ -1,12 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'aws-flow-core'
3
- s.version = '1.0.0'
4
- s.date = Time.now
5
- s.summary = "AWS Flow Core"
6
- s.description = "Library to provide all the base asynchronous constructs that aws-flow uses"
7
- s.authors = "Michael Steger"
8
- s.email = ""
9
- s.files = `git ls-files`.split("\n")
10
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
11
- s.require_paths << "lib/aws/"
12
- end
@@ -1,26 +0,0 @@
1
- ##
2
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/apache2.0
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
14
- ##
15
-
16
- def require_all(path)
17
- glob = File.join(File.dirname(__FILE__), path, "*.rb")
18
- Dir[glob].each { |f| require f}
19
- Dir[glob].map { |f| File.basename(f) }
20
- end
21
-
22
-
23
- # Everything depends on fiber, so we have to require that before anything else
24
- require 'aws/flow/fiber'
25
-
26
- $RUBY_FLOW_FILES = require_all 'flow/'
@@ -1,134 +0,0 @@
1
- ##
2
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/apache2.0
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
14
- ##
15
-
16
- # This file contains AsyncBacktrace, which takes care of decorating and properly filtering backtraces
17
-
18
- module AWS
19
- module Flow
20
- module Core
21
- # @!visibility private
22
- class AsyncBacktrace
23
-
24
- # @!visibility private
25
- def initialize(parent, backtrace)
26
- @backtrace = AsyncBacktrace.filter(backtrace)
27
- @parent = parent
28
- end
29
-
30
- # @!visibility private
31
- def backtrace
32
- if @parent
33
- AsyncBacktrace.merge(@backtrace, @parent.backtrace)
34
- else
35
- @backtrace
36
- end
37
- end
38
-
39
- # @!visibility private
40
- class << self
41
-
42
- # @!visibility private
43
- def create(parent, frames_to_skip)
44
-
45
- unless @disable_async_backtrace
46
- b = AsyncBacktrace.caller(frames_to_skip)
47
- AsyncBacktrace.new(parent, b)
48
- end
49
- end
50
-
51
- # @!visibility private
52
- def create_from_exception(parent, exception)
53
- unless @disable_async_backtrace
54
- AsyncBacktrace.new(parent, exception.backtrace);
55
- end
56
- end
57
-
58
- # Remove all framework related frames after application frames. Keep framework frames before application
59
- # frames.
60
- #
61
- # @todo
62
- # The correct implementation should not have framework frames before application frames as it is expected to
63
- # call Kernel.caller with the correct number. But in cases when due to changes this number is not correct
64
- # the frames are kept to not create confusion.
65
- #
66
- def filter(backtrace)
67
- if @disable_filtering
68
- backtrace
69
- else
70
- do_filter(backtrace)
71
- end
72
- end
73
-
74
- # @!visibility private
75
- def merge(*backtraces)
76
- result = []
77
- backtraces.each do | b |
78
- if b
79
- result << "------ continuation ------" if result.size > 0
80
- result += b
81
- end
82
- end
83
- result
84
- end
85
-
86
- # @!visibility private
87
- def disable_filtering
88
- @disable_filtering = true
89
- end
90
-
91
- # @!visibility private
92
- def enable_filtering
93
- @disable_filtering = false
94
- end
95
-
96
- # @!visibility private
97
- def disable
98
- @disable_async_backtrace = true
99
- end
100
-
101
- # @!visibility private
102
- def enable
103
- @disable_async_backtrace = false
104
- end
105
-
106
- # @!visibility private
107
- def caller(skip)
108
- random_var = Kernel.caller 0
109
- this_stuff = 1.upto(6).map { |x| Kernel.caller(x) }
110
- other_var = Kernel.caller skip
111
- Kernel.caller(@disable_filtering ? 0 : skip)
112
- end
113
-
114
- private
115
-
116
- # @!visibility private
117
- def do_filter(backtrace)
118
- return nil unless backtrace
119
- # keep asynchrony frames at the top of the backtrace only
120
- # then cut all frames starting from asynchrony frame
121
- skip_asynchrony_frames = false
122
- @backtrace = backtrace.take_while do |frame|
123
- if ! $RUBY_FLOW_FILES.select {|file| Regexp.new(file) =~ frame}.empty?
124
- !skip_asynchrony_frames
125
- else
126
- skip_asynchrony_frames = true
127
- end
128
- end
129
- end
130
- end
131
- end
132
- end
133
- end
134
- end
@@ -1,195 +0,0 @@
1
- ##
2
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/apache2.0
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
14
- ##
15
-
16
- # This module contains the Root of the heirarchy for calls into flow, the AsyncScope
17
-
18
- module AWS
19
- module Flow
20
- module Core
21
-
22
- def gate_by_version(version, method, &block)
23
- if RUBY_VERSION.send(method, version)
24
- block.call
25
- end
26
- end
27
-
28
- # @!visibility private
29
- class AsyncScope
30
- attr_accessor :stackTrace, :root, :failure, :root_context
31
-
32
- def is_complete?
33
- @root_context.complete
34
- end
35
-
36
- def get_closest_containing_scope
37
- @root_error_handler
38
- end
39
-
40
- def cancel(error); @root_error_handler.cancel(error); end
41
-
42
- def initialize(&block)
43
- @root_context = RootAsyncScope.new
44
-
45
-
46
-
47
- # 1 for the function that skips frames
48
- # 1 for the create function
49
- # 1 for the the initialize of the backtrace
50
-
51
- # "./lib/aws/rubyflow/asyncBacktrace.rb:75:in `caller'"
52
- # "./lib/aws/rubyflow/asyncBacktrace.rb:21:in `create'"
53
- # "./lib/aws/rubyflow/asyncScope.rb:18:in `initialize'"
54
-
55
- @root_context.backtrace = AsyncBacktrace.create(nil, 3)
56
- @root_error_handler = BeginRescueEnsure.new(:parent => @root_context)
57
- begin
58
- @root_error_handler.begin lambda { block.call if ! block.nil? }
59
- @root_error_handler.rescue(Exception, lambda { |e| raise e })
60
- end
61
- @root_context << @root_error_handler
62
- end
63
-
64
- # Collects all the heirs of a task for use in async_stack_dump
65
- def get_heirs
66
- @root_error_handler.get_heirs
67
- end
68
-
69
- # Execute all queued tasks. If execution of those tasks results in addition of new tasks to the queue, execute
70
- # them as well.
71
- #
72
- # Unless there are external dependencies or bugs in the tasks to be executed, a single call to this method
73
- # performs the complete asynchronous execution.
74
- #
75
- # @note In the presence of external dependencies, it is expected that {AsyncScope#eventLoop} is called every
76
- # time after a change in the state in a dependency can unblock asynchronous execution.
77
- #
78
- def eventLoop
79
- #TODO Figure out when to raise Done raise "Done" if ! @root_task.alive?
80
- raise IllegalStateException, "Already complete" if is_complete?
81
- @root_context.eventLoop
82
- # TODO Does this need to be taken care of? It's supposed to protect
83
- # against people having errors that are classes, so like, passing
84
- # Exception into cancel. We might want to just catch that at the
85
- # entry point
86
- if @root_context.failure
87
- if @root_context.failure.respond_to? :message
88
- failure_message = @root_context.failure.message + "\n" +
89
- @root_context.failure.backtrace.join("\n")
90
- raise @root_context.failure, failure_message
91
- else
92
- raise @root_context.failure
93
- end
94
- end
95
-
96
- return is_complete?
97
- end
98
-
99
- def <<(task)
100
- @root_context << task
101
- task.parent = @root_context
102
- end
103
- end
104
-
105
- # @!visibility private
106
- class RootAsyncScope < FlowFiber
107
-
108
- attr_accessor :backtrace, :failure, :executor, :complete
109
-
110
- def initialize(options = {}, &block)
111
- @parent = options[:parent_context]
112
- @daemon = options[:daemon]
113
- @context = @parent
114
- @executor = AsyncEventLoop.new
115
- @task_queue = []
116
- @complete = false
117
- @task_queue << Task.new(context, &block) if block
118
- end
119
-
120
- # The only thing that should be removed from the RootAsyncScope is the
121
- # root BeginRescueEnsure, so upon removal we are complete
122
- def remove(task)
123
- @complete = true
124
- end
125
-
126
- # As with remove, the only thing that is under RootAsyncScope should be
127
- # the root BeginRescueEnsure, so upon failure we will be complete. Also
128
- # sets failure variable for later raising.
129
- def fail(task, error)
130
- @failure = error
131
- @complete = true
132
- end
133
-
134
- def <<(this_task)
135
- @executor << this_task
136
- end
137
-
138
- # Reture self, a RootAsyncScope is the closest containing scope
139
- def get_closest_containing_scope
140
- self
141
- end
142
-
143
- # Call out to the AsyncEventLoop
144
- def eventLoop
145
- @executor.executeQueuedTasks
146
- end
147
-
148
-
149
- private
150
- DELEGATED_METHODS = [:push, :<<, :enq, :empty?, :length, :size, :delete, :shift]
151
-
152
- def method_missing(method_name, *args)
153
- if DELEGATED_METHODS.include? method_name
154
- @executor.send(method_name, *args)
155
- else
156
- super
157
- end
158
- end
159
- end
160
-
161
- # @!visibility private
162
- class AsyncEventLoop
163
-
164
- def initialize
165
- @tasks = []
166
- end
167
-
168
- def remove(task)
169
- @tasks.delete(task)
170
- end
171
- # TODO Make sure that it's okay to fail from the AsyncEventLoop, and that
172
- # this is the correct behavior
173
- def fail(task, error)
174
- raise error
175
- end
176
- def <<(task)
177
- @tasks << task
178
-
179
- end
180
-
181
-
182
- # TODO should this be synchronized somehow?
183
-
184
- # Actually executes the eventLoop
185
- def executeQueuedTasks
186
- until @tasks.empty?
187
- task = @tasks.shift
188
- task.resume if task.alive?
189
- end
190
- end
191
- end
192
-
193
- end
194
- end
195
- end