aws-flow 1.0.8 → 1.0.9
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.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Rakefile +18 -31
- data/aws-flow.gemspec +1 -1
- data/lib/aws/decider.rb +1 -2
- data/lib/aws/decider/activity.rb +99 -53
- data/lib/aws/decider/activity_definition.rb +43 -7
- data/lib/aws/decider/async_decider.rb +56 -57
- data/lib/aws/decider/async_retrying_executor.rb +4 -5
- data/lib/aws/decider/data_converter.rb +2 -2
- data/lib/aws/decider/decider.rb +46 -41
- data/lib/aws/decider/decision_context.rb +2 -2
- data/lib/aws/decider/exceptions.rb +6 -6
- data/lib/aws/decider/executor.rb +15 -11
- data/lib/aws/decider/flow_defaults.rb +54 -22
- data/lib/aws/decider/generic_client.rb +7 -7
- data/lib/aws/decider/history_helper.rb +0 -0
- data/lib/aws/decider/implementation.rb +5 -5
- data/lib/aws/decider/options.rb +285 -155
- data/lib/aws/decider/state_machines.rb +10 -10
- data/lib/aws/decider/task_handler.rb +5 -5
- data/lib/aws/decider/task_poller.rb +152 -15
- data/lib/aws/decider/utilities.rb +14 -14
- data/lib/aws/decider/version.rb +1 -1
- data/lib/aws/decider/worker.rb +21 -20
- data/lib/aws/decider/workflow_client.rb +78 -31
- data/lib/aws/decider/workflow_clock.rb +1 -1
- data/lib/aws/decider/workflow_definition.rb +5 -5
- data/lib/aws/decider/workflow_definition_factory.rb +1 -1
- data/lib/aws/decider/workflow_enabled.rb +1 -1
- data/lib/aws/flow/async_backtrace.rb +19 -18
- data/lib/aws/flow/async_scope.rb +32 -16
- data/lib/aws/flow/begin_rescue_ensure.rb +61 -56
- data/lib/aws/flow/fiber.rb +14 -6
- data/lib/aws/flow/flow_utils.rb +9 -6
- data/lib/aws/flow/future.rb +43 -18
- data/lib/aws/flow/implementation.rb +34 -18
- data/lib/aws/flow/simple_dfa.rb +12 -4
- data/lib/aws/flow/tasks.rb +120 -86
- data/{test/aws → spec/aws/integration}/integration_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/async_backtrace_spec.rb +1 -0
- data/{test/aws → spec/aws/unit}/async_scope_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/begin_rescue_ensure_spec.rb +90 -2
- data/{test/aws → spec/aws/unit}/decider_spec.rb +41 -53
- data/{test/aws → spec/aws/unit}/external_task_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/factories.rb +0 -0
- data/{test/aws → spec/aws/unit}/fiber_condition_variable_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/fiber_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/flow_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/future_spec.rb +0 -0
- data/{test/aws → spec/aws/unit}/preinclude_tests.rb +0 -0
- data/{test/aws → spec/aws/unit}/rubyflow.rb +0 -0
- data/{test/aws → spec/aws/unit}/simple_dfa_spec.rb +0 -0
- data/{test/aws → spec}/spec_helper.rb +0 -0
- metadata +30 -30
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74aff8c011e1dda48d38cf639ec0f6fcc1e2ee5a
|
4
|
+
data.tar.gz: 1b23c646c3afe8a5827d21feb8cc1701fad571b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bee020ffb919c382d69db2ef2860e5f134fc49ec7fa90bee420256a6adba01e6daf86e5aad6d8bc30110c2805205298f9f53623ec0e0a91077f511843a64406e
|
7
|
+
data.tar.gz: d1edebf2776156f6a881f156c92ed93f21c80d534d464b383c4c56c13a45eabbb7805199cd8abbd968578e02c9611b0f313469c4433186c7c114c22fc2981d86
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -13,38 +13,25 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
##
|
15
15
|
|
16
|
-
require
|
16
|
+
require "rspec/core/rake_task"
|
17
17
|
|
18
|
-
desc "Run unit tests
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
t.spec_files = FileList['test/**/*.rb']
|
23
|
-
t.spec_files.delete_if do |x|
|
24
|
-
(x =~ /.*factories.rb/) ||
|
25
|
-
(x =~ /.*spec_helper.rb/) ||
|
26
|
-
(x =~ /.*preinclude_tests.rb/) ||
|
27
|
-
(x =~ /.*integration.*/)
|
28
|
-
end
|
29
|
-
t.spec_files.unshift("test/aws/factories.rb")
|
30
|
-
t.spec_files.unshift("test/aws/spec_helper.rb")
|
31
|
-
t.spec_files.unshift("test/aws/preinclude_tests.rb")
|
18
|
+
desc "Run unit tests"
|
19
|
+
RSpec::Core::RakeTask.new(:unit_tests) do |spec|
|
20
|
+
spec.rspec_opts = ['--color', '--format nested']
|
21
|
+
spec.pattern = 'spec/**/unit/*.rb'
|
32
22
|
end
|
33
|
-
task :test => :unit_tests
|
34
23
|
|
35
|
-
desc "Run integration tests
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
t.spec_opts = ['--color', '--format nested']
|
40
|
-
t.spec_files = FileList['test/**/*.rb']
|
41
|
-
t.spec_files.delete_if do |x|
|
42
|
-
(x =~ /.*factories.rb/) ||
|
43
|
-
(x =~ /.*spec_helper.rb/) ||
|
44
|
-
(x =~ /.*preinclude_tests.rb/)
|
45
|
-
end
|
46
|
-
t.spec_files.unshift("test/aws/factories.rb")
|
47
|
-
t.spec_files.unshift("test/aws/spec_helper.rb")
|
48
|
-
t.spec_files.unshift("test/aws/preinclude_tests.rb")
|
24
|
+
desc "Run integration tests"
|
25
|
+
RSpec::Core::RakeTask.new(:integration_tests) do |spec|
|
26
|
+
spec.rspec_opts = ['--color', '--format nested']
|
27
|
+
spec.pattern = 'spec/**/integration/*.rb'
|
49
28
|
end
|
50
|
-
|
29
|
+
|
30
|
+
desc "Run all tests"
|
31
|
+
RSpec::Core::RakeTask.new(:all_tests) do |spec|
|
32
|
+
spec.rspec_opts = ['--color', '--format nested']
|
33
|
+
spec.pattern = 'spec/**/*.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
task :test => :all_tests
|
37
|
+
|
data/aws-flow.gemspec
CHANGED
@@ -10,6 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ''
|
11
11
|
s.files = `git ls-files`.split("\n").reject {|file| file =~ /aws-flow-core/}
|
12
12
|
s.require_paths << "lib/aws/"
|
13
|
-
s.add_dependency "aws-sdk", "~> 1"
|
13
|
+
s.add_dependency "aws-sdk", "~> 1", ">= 1.36.2"
|
14
14
|
s.add_dependency "aws-flow-core", ">= 1.0.1"
|
15
15
|
end
|
data/lib/aws/decider.rb
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
#++
|
15
15
|
|
16
|
-
|
17
16
|
require 'aws/flow'
|
18
17
|
include AWS::Flow::Core
|
19
18
|
|
@@ -48,7 +47,7 @@ require "aws/decider/flow_defaults"
|
|
48
47
|
require "aws/decider/implementation"
|
49
48
|
require "aws/decider/version"
|
50
49
|
|
51
|
-
#
|
50
|
+
# @api private
|
52
51
|
def get_const(name)
|
53
52
|
name = name.split('::').reverse
|
54
53
|
current = Object
|
data/lib/aws/decider/activity.rb
CHANGED
@@ -17,37 +17,48 @@ module AWS
|
|
17
17
|
module Flow
|
18
18
|
|
19
19
|
# Represents information about an open request.
|
20
|
-
#
|
20
|
+
# @api private
|
21
21
|
class OpenRequestInfo
|
22
22
|
attr_accessor :completion_handle, :result, :blocking_promise, :description, :run_id
|
23
23
|
end
|
24
24
|
|
25
|
+
# Contains metadata about an activity.
|
26
|
+
# @api private
|
25
27
|
class ActivityMetadata
|
28
|
+
# The stored ID of the activity.
|
26
29
|
attr_reader :activity_id
|
30
|
+
|
31
|
+
# Initializes a new ActivityMetadata object.
|
32
|
+
#
|
33
|
+
# @param activity_id
|
34
|
+
# The ID of the activity.
|
35
|
+
#
|
27
36
|
def initialize(activity_id); @activity_id = activity_id; end
|
28
37
|
end
|
29
38
|
|
30
|
-
|
31
39
|
# A generic activity client that can be used to perform standard activity actions.
|
32
40
|
class GenericActivityClient < GenericClient
|
33
|
-
|
34
|
-
#
|
41
|
+
|
42
|
+
# The data converter used for serializing/deserializing data when sending
|
43
|
+
# requests to and receiving results from workflow executions of this
|
44
|
+
# workflow type. By default, this is {YAMLDataConverter}.
|
35
45
|
attr_accessor :data_converter
|
36
46
|
|
37
47
|
# The decision helper used by the activity client.
|
38
48
|
attr_accessor :decision_helper
|
39
49
|
|
40
|
-
# A hash of ActivityRuntimeOptions for the activity client
|
50
|
+
# A hash of {ActivityRuntimeOptions} for the activity client.
|
41
51
|
attr_accessor :options
|
42
52
|
|
43
|
-
|
53
|
+
# Returns the default option class for the activity client, which is {ActivityRuntimeOptions}.
|
44
54
|
def self.default_option_class; ActivityRuntimeOptions; end
|
45
55
|
|
46
|
-
# Separates the activity name from the activity type at the point of the last
|
56
|
+
# Separates the activity name from the activity type at the point of the last period.
|
47
57
|
#
|
48
58
|
# @param [String] name
|
49
59
|
# The name of the activity type.
|
50
60
|
#
|
61
|
+
# @api private
|
51
62
|
def activity_name_from_activity_type(name)
|
52
63
|
return name.to_s.split(".").last.to_sym
|
53
64
|
end
|
@@ -57,7 +68,8 @@ module AWS
|
|
57
68
|
# @param [DecisionHelper] decision_helper
|
58
69
|
# The decision helper to use for the activity client.
|
59
70
|
#
|
60
|
-
# @param [ActivityOptions] options
|
71
|
+
# @param [ActivityOptions] options
|
72
|
+
# The activity options to set for the activity client.
|
61
73
|
#
|
62
74
|
def initialize(decision_helper, options)
|
63
75
|
@decision_helper = decision_helper
|
@@ -68,16 +80,17 @@ module AWS
|
|
68
80
|
super
|
69
81
|
end
|
70
82
|
|
71
|
-
#
|
83
|
+
# Registers and schedules a new activity type, provided a name and block of options.
|
72
84
|
#
|
73
85
|
# @param method_name
|
74
|
-
# The name of the activity type to define
|
86
|
+
# *Required*. The name of the activity type to define.
|
75
87
|
#
|
76
88
|
# @param args
|
77
|
-
# Arguments for the method
|
89
|
+
# *Required*. Arguments for the method provided in *method_name*.
|
78
90
|
#
|
79
91
|
# @param block
|
80
|
-
# A block of {ActivityOptions}
|
92
|
+
# *Required*. A block of {ActivityOptions} to use when registering the new {ActivityType}. This can be set to an
|
93
|
+
# empty block, in which case, the default activity options will be used.
|
81
94
|
#
|
82
95
|
def method_missing(method_name, *args, &block)
|
83
96
|
options = Utilities::interpret_block_for_options(ActivityOptions, block)
|
@@ -101,20 +114,20 @@ module AWS
|
|
101
114
|
result
|
102
115
|
end
|
103
116
|
|
104
|
-
#
|
117
|
+
# @api private
|
105
118
|
def retry_alias_to_method(retry_alias)
|
106
119
|
retry_alias.to_s[/__(.*)_retry/, 1].to_sym
|
107
120
|
end
|
108
121
|
|
109
|
-
#
|
122
|
+
# @api private
|
110
123
|
def method_to_retry_alias(method_name)
|
111
124
|
"#{__method_name.to_s + "_retry"}".to_sym
|
112
125
|
end
|
113
126
|
|
114
127
|
# Requests that the activity is canceled.
|
115
128
|
#
|
116
|
-
# @param [
|
117
|
-
# The
|
129
|
+
# @param [WorkflowFuture] to_cancel
|
130
|
+
# The {WorkflowFuture} for the task to be canceled.
|
118
131
|
#
|
119
132
|
def request_cancel_activity_task(to_cancel)
|
120
133
|
metadata = to_cancel.metadata
|
@@ -124,9 +137,9 @@ module AWS
|
|
124
137
|
@decision_helper[metadata.activity_id].consume(:cancel)
|
125
138
|
end
|
126
139
|
|
127
|
-
# A handler for the ActivityClassCanceled event.
|
140
|
+
# A handler for the `ActivityClassCanceled` event.
|
128
141
|
#
|
129
|
-
# @param [
|
142
|
+
# @param [AWS::SimpleWorkflow::HistoryEvent] event
|
130
143
|
# The event data.
|
131
144
|
#
|
132
145
|
def handle_activity_task_canceled(event)
|
@@ -141,9 +154,9 @@ module AWS
|
|
141
154
|
end
|
142
155
|
end
|
143
156
|
|
144
|
-
# A handler for the ActivityClassTimedOut event.
|
157
|
+
# A handler for the `ActivityClassTimedOut` event.
|
145
158
|
#
|
146
|
-
# @param [
|
159
|
+
# @param [AWS::SimpleWorkflow::HistoryEvent] event
|
147
160
|
# The event data.
|
148
161
|
#
|
149
162
|
def handle_activity_task_timed_out(event)
|
@@ -160,7 +173,7 @@ module AWS
|
|
160
173
|
end
|
161
174
|
end
|
162
175
|
|
163
|
-
# A handler for the
|
176
|
+
# A handler for the `ActivityTaskFailed` event.
|
164
177
|
#
|
165
178
|
# @param [ActivityClassFailed] event
|
166
179
|
# The event data.
|
@@ -181,9 +194,9 @@ module AWS
|
|
181
194
|
open_request_info.completion_handle.fail(failure)
|
182
195
|
end
|
183
196
|
|
184
|
-
# A handler for the
|
197
|
+
# A handler for the `ScheduleActivityTaskFailed` event.
|
185
198
|
#
|
186
|
-
# @param [
|
199
|
+
# @param [AWS::SimpleWorkflow::HistoryEvent] event
|
187
200
|
# The event data.
|
188
201
|
#
|
189
202
|
def handle_schedule_activity_task_failed(event)
|
@@ -199,9 +212,9 @@ module AWS
|
|
199
212
|
end
|
200
213
|
end
|
201
214
|
|
202
|
-
# A handler for the
|
215
|
+
# A handler for the `ActivityClassCompleted` event.
|
203
216
|
#
|
204
|
-
# @param [
|
217
|
+
# @param [AWS::SimpleWorkflow::HistoryEvent] event
|
205
218
|
# The event data.
|
206
219
|
#
|
207
220
|
def handle_activity_task_completed(event)
|
@@ -215,19 +228,19 @@ module AWS
|
|
215
228
|
end
|
216
229
|
end
|
217
230
|
|
218
|
-
# Schedules
|
231
|
+
# Schedules a named activity.
|
219
232
|
#
|
220
233
|
# @param [String] name
|
221
|
-
# The name of the activity to schedule.
|
234
|
+
# *Required*. The name of the activity to schedule.
|
222
235
|
#
|
223
|
-
# @param [String]
|
224
|
-
#
|
236
|
+
# @param [String] activity_type
|
237
|
+
# *Required*. The activity type for this scheduled activity.
|
225
238
|
#
|
226
|
-
# @param [Object]
|
227
|
-
#
|
239
|
+
# @param [Object] input
|
240
|
+
# *Required*. Additional data passed to the activity.
|
228
241
|
#
|
229
|
-
# @param [ActivityOptions]
|
230
|
-
#
|
242
|
+
# @param [ActivityOptions] options
|
243
|
+
# *Required*. {ActivityOptions} to set for the scheduled activity.
|
231
244
|
#
|
232
245
|
def schedule_activity(name, activity_type, input, options)
|
233
246
|
options = Utilities::merge_all_options(@option_map[activity_name_from_activity_type(name)], options)
|
@@ -272,7 +285,7 @@ module AWS
|
|
272
285
|
# we should serialize the error, and stuff that into details, so
|
273
286
|
# that things above us can pull it out correctly. We don't have to
|
274
287
|
# do this for ActivityTaskFailedException, as the details is
|
275
|
-
# *already* serialized
|
288
|
+
# *already* serialized.
|
276
289
|
if error.is_a? ActivityTaskFailedException
|
277
290
|
details = @data_converter.load(error.details)
|
278
291
|
error.cause = details
|
@@ -299,21 +312,28 @@ module AWS
|
|
299
312
|
|
300
313
|
# Represents an activity client.
|
301
314
|
class ActivityClient
|
302
|
-
|
315
|
+
|
316
|
+
# Gets the data converter for the activity client.
|
303
317
|
def data_converter
|
304
318
|
@generic_client.data_converter
|
305
319
|
end
|
306
320
|
|
307
|
-
# Sets the data converter for the
|
321
|
+
# Sets the data converter for the activity client.
|
322
|
+
#
|
323
|
+
# @param other
|
324
|
+
# The data converter to set.
|
325
|
+
#
|
308
326
|
def data_converter=(other)
|
309
327
|
@generic_client.data_converter = other
|
310
328
|
end
|
311
329
|
|
312
330
|
# Exponentially retries the supplied method with optional settings.
|
313
331
|
#
|
314
|
-
# @param [String] method_name
|
332
|
+
# @param [String] method_name
|
333
|
+
# The method name to retry.
|
315
334
|
#
|
316
|
-
# @param [ExponentialRetryOptions] block
|
335
|
+
# @param [ExponentialRetryOptions] block
|
336
|
+
# A hash of {ExponentialRetryOptions} to use.
|
317
337
|
#
|
318
338
|
def exponential_retry(method_name, &block)
|
319
339
|
@generic_client.retry(method_name, lambda {|first, time_of_failure, attempts| 1}, block)
|
@@ -323,10 +343,11 @@ module AWS
|
|
323
343
|
# Methods and constants related to activities.
|
324
344
|
#
|
325
345
|
# @!attribute activity_client
|
326
|
-
# Gets the
|
346
|
+
# Gets the {ActivityClient} contained by the class.
|
327
347
|
#
|
328
348
|
# @!attribute activities
|
329
|
-
# Gets
|
349
|
+
# Gets the list of {ActivityType} objects that were created by the
|
350
|
+
# {#activity} method.
|
330
351
|
#
|
331
352
|
module Activities
|
332
353
|
@precursors ||= []
|
@@ -335,21 +356,34 @@ module AWS
|
|
335
356
|
base.send :include, InstanceMethods
|
336
357
|
end
|
337
358
|
module InstanceMethods
|
359
|
+
# Sets the {ActivityExecutionContext} instance for the activity task.
|
338
360
|
attr_writer :_activity_execution_context
|
361
|
+
|
362
|
+
# Gets the activity execution context for the activity task. Raises an `IllegalStateException` if the activity
|
363
|
+
# has no context.
|
364
|
+
#
|
365
|
+
# @return [ActivityExecutionContext] The execution context for this activity.
|
366
|
+
#
|
339
367
|
def activity_execution_context
|
340
368
|
raise IllegalStateException.new("No activity execution context") unless @_activity_execution_context
|
341
369
|
@_activity_execution_context
|
342
370
|
end
|
371
|
+
|
372
|
+
# Records a heartbeat for the activity, indicating to Amazon SWF that the activity is still making progress.
|
373
|
+
#
|
374
|
+
# @param [String] details
|
375
|
+
# If specified, contains details about the progress of the activity task. Up to 2048
|
376
|
+
# characters can be provided.
|
377
|
+
#
|
343
378
|
def record_activity_heartbeat(details)
|
344
379
|
@_activity_execution_context.record_activity_heartbeat(details)
|
345
380
|
end
|
346
381
|
end
|
347
382
|
|
348
|
-
|
349
|
-
# @!visibility private
|
383
|
+
# @api private
|
350
384
|
extend Utilities::UpwardLookups
|
351
385
|
|
352
|
-
#
|
386
|
+
# @api private
|
353
387
|
def look_upwards(variable)
|
354
388
|
precursors = self.ancestors.dup
|
355
389
|
precursors.delete(self)
|
@@ -357,21 +391,33 @@ module AWS
|
|
357
391
|
end
|
358
392
|
property(:activities, [])
|
359
393
|
|
360
|
-
#
|
394
|
+
# @api private
|
361
395
|
def _options; @activities.map(&:options); end
|
362
396
|
|
363
|
-
# Defines one or more activities
|
397
|
+
# Defines one or more activities with {ActivityOptions} provided in the
|
398
|
+
# supplied block.
|
364
399
|
#
|
365
400
|
# @param [Array] activity_names
|
366
|
-
# The names of the activities to define.
|
401
|
+
# The names of the activities to define. These names will be used to
|
402
|
+
# create {ActivityType} objects, one per name.
|
403
|
+
#
|
404
|
+
# Each activity type is named as *prefix.activity_name*, where the
|
405
|
+
# *prefix* is specified in the options block, and each *activity_name*
|
406
|
+
# comes from the list passed to this parameter.
|
367
407
|
#
|
368
408
|
# @param [Hash] block
|
369
409
|
# {ActivityOptions} to use on the defined activities.
|
370
410
|
#
|
411
|
+
# The following options are *required* when registering an activity:
|
412
|
+
#
|
413
|
+
# * `version` - The version of the activity type.
|
414
|
+
# * `task_list` - The task list used to poll for activity tasks.
|
415
|
+
#
|
371
416
|
# @example Defining an activity
|
372
417
|
# new_activity_class = Class.new(MyActivity) do
|
373
418
|
# extend Activities
|
374
|
-
#
|
419
|
+
#
|
420
|
+
# activity :activity1 do
|
375
421
|
# {
|
376
422
|
# :default_task_heartbeat_timeout => "3600",
|
377
423
|
# :default_task_list => task_list,
|
@@ -379,10 +425,12 @@ module AWS
|
|
379
425
|
# :default_task_schedule_to_start_timeout => "20",
|
380
426
|
# :default_task_start_to_close_timeout => "20",
|
381
427
|
# :version => "1",
|
382
|
-
# :prefix_name => "
|
428
|
+
# :prefix_name => "ExampleActivity"
|
383
429
|
# }
|
384
430
|
# end
|
385
|
-
#
|
431
|
+
#
|
432
|
+
# def activity1
|
433
|
+
# puts "Hello!"
|
386
434
|
# end
|
387
435
|
# end
|
388
436
|
def activity(*activity_names, &block)
|
@@ -396,9 +444,8 @@ module AWS
|
|
396
444
|
end
|
397
445
|
end
|
398
446
|
|
399
|
-
#
|
400
|
-
#
|
401
|
-
# @!visibility private
|
447
|
+
# @deprecated Use {Activities} instead.
|
448
|
+
# @api private
|
402
449
|
module Activity
|
403
450
|
include Activities
|
404
451
|
def self.extended(base)
|
@@ -406,6 +453,5 @@ module AWS
|
|
406
453
|
end
|
407
454
|
end
|
408
455
|
|
409
|
-
|
410
456
|
end
|
411
457
|
end
|