aws-flow 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -92,7 +92,7 @@ module AWS
|
|
92
92
|
# Represents a policy for retrying failed tasks.
|
93
93
|
class RetryPolicy
|
94
94
|
|
95
|
-
# Creates a new RetryPolicy instance
|
95
|
+
# Creates a new `RetryPolicy` instance.
|
96
96
|
#
|
97
97
|
# @param retry_function
|
98
98
|
# The method to be called for each retry attempt.
|
@@ -134,7 +134,7 @@ module AWS
|
|
134
134
|
#return (!@exceptions_to_exclude.include?(failure) && @exceptions_to_include.include?(failure))
|
135
135
|
end
|
136
136
|
|
137
|
-
# Schedules a new retry attempt
|
137
|
+
# Schedules a new retry attempt.
|
138
138
|
#
|
139
139
|
# @param first_attempt
|
140
140
|
#
|
@@ -156,7 +156,6 @@ module AWS
|
|
156
156
|
end
|
157
157
|
return -1 if failure == nil
|
158
158
|
|
159
|
-
|
160
159
|
# For reverse compatbility purposes, we must ensure that this function
|
161
160
|
# can take 3 arguments. However, we must also consume options in order
|
162
161
|
# for the default retry function to work correctly. Because we support
|
@@ -168,8 +167,8 @@ module AWS
|
|
168
167
|
retry_seconds = @retry_function.call(*call_args)
|
169
168
|
# Check to see if we should jitter or not and pass in the jitter
|
170
169
|
# function to retry function accordingly.
|
171
|
-
if @should_jitter
|
172
|
-
|
170
|
+
if @should_jitter && retry_seconds > 0
|
171
|
+
retry_seconds += @jitter_function.call(execution_id, retry_seconds/2)
|
173
172
|
end
|
174
173
|
return retry_seconds
|
175
174
|
end
|
@@ -15,8 +15,8 @@
|
|
15
15
|
|
16
16
|
module AWS
|
17
17
|
module Flow
|
18
|
-
#
|
19
|
-
# properly, and they are very handy for debugging
|
18
|
+
# Converts an object to YAML. Exceptions are handled differently because YAML doesn't propagate backtraces
|
19
|
+
# properly, and they are very handy for debugging.
|
20
20
|
class YAMLDataConverter
|
21
21
|
|
22
22
|
def dump(object)
|
data/lib/aws/decider/decider.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
module AWS
|
17
17
|
module Flow
|
18
18
|
|
19
|
-
#
|
19
|
+
# Groups a method name with an associated data converter.
|
20
20
|
class MethodPair
|
21
21
|
# The method name for the method pair.
|
22
22
|
attr_accessor :method_name
|
@@ -61,17 +61,19 @@ module AWS
|
|
61
61
|
@workflow_context = workflow_context
|
62
62
|
end
|
63
63
|
|
64
|
-
# Handler for the ExternalWorkflowExecutionCancelRequested event.
|
64
|
+
# Handler for the `ExternalWorkflowExecutionCancelRequested` event.
|
65
65
|
#
|
66
|
-
# @param [Object] event
|
66
|
+
# @param [Object] event
|
67
|
+
# The event instance.
|
67
68
|
#
|
68
69
|
def handle_external_workflow_execution_cancel_requested(event)
|
69
70
|
# NOOP
|
70
71
|
end
|
71
72
|
|
72
|
-
# Handler for the ChildWorkflowExecutionCanceled event.
|
73
|
+
# Handler for the `ChildWorkflowExecutionCanceled` event.
|
73
74
|
#
|
74
|
-
# @param [Object] event
|
75
|
+
# @param [Object] event
|
76
|
+
# The event instance.
|
75
77
|
#
|
76
78
|
def handle_child_workflow_execution_canceled(event)
|
77
79
|
handle_event(event,
|
@@ -87,11 +89,11 @@ module AWS
|
|
87
89
|
end
|
88
90
|
|
89
91
|
|
90
|
-
# Handler for the ChildWorkflowExecutionCompleted event.
|
92
|
+
# Handler for the `ChildWorkflowExecutionCompleted` event.
|
91
93
|
#
|
92
|
-
# @param [Object] event
|
94
|
+
# @param [Object] event
|
95
|
+
# The event instance.
|
93
96
|
#
|
94
|
-
|
95
97
|
def handle_child_workflow_execution_completed(event)
|
96
98
|
handle_event(event,
|
97
99
|
{:id_methods => [:workflow_execution, :workflow_id],
|
@@ -101,9 +103,10 @@ module AWS
|
|
101
103
|
})
|
102
104
|
end
|
103
105
|
|
104
|
-
# Handler for the ChildWorkflowExecutionFailed event.
|
106
|
+
# Handler for the `ChildWorkflowExecutionFailed` event.
|
105
107
|
#
|
106
|
-
# @param [Object] event
|
108
|
+
# @param [Object] event
|
109
|
+
# The event instance.
|
107
110
|
#
|
108
111
|
def handle_child_workflow_execution_failed(event)
|
109
112
|
handle_event(event,
|
@@ -126,9 +129,10 @@ module AWS
|
|
126
129
|
end
|
127
130
|
|
128
131
|
|
129
|
-
# Handler for the ChildWorkflowExecutionStarted event.
|
132
|
+
# Handler for the `ChildWorkflowExecutionStarted` event.
|
130
133
|
#
|
131
|
-
# @param [Object] event
|
134
|
+
# @param [Object] event
|
135
|
+
# The event instance.
|
132
136
|
#
|
133
137
|
def handle_child_workflow_execution_started(event)
|
134
138
|
handle_event(event,
|
@@ -141,9 +145,10 @@ module AWS
|
|
141
145
|
})
|
142
146
|
end
|
143
147
|
|
144
|
-
# Handler for the ChildWorkflowExecutionTerminated event.
|
148
|
+
# Handler for the `ChildWorkflowExecutionTerminated` event.
|
145
149
|
#
|
146
|
-
# @param [Object] event
|
150
|
+
# @param [Object] event
|
151
|
+
# The event instance.
|
147
152
|
#
|
148
153
|
def handle_child_workflow_execution_terminated(event)
|
149
154
|
handle_event(event,
|
@@ -157,9 +162,10 @@ module AWS
|
|
157
162
|
})
|
158
163
|
end
|
159
164
|
|
160
|
-
# Handler for the ChildWorkflowExecutionTimedOut event.
|
165
|
+
# Handler for the `ChildWorkflowExecutionTimedOut` event.
|
161
166
|
#
|
162
|
-
# @param [Object] event
|
167
|
+
# @param [Object] event
|
168
|
+
# The event instance.
|
163
169
|
#
|
164
170
|
def handle_child_workflow_execution_timed_out(event)
|
165
171
|
handle_event(event,
|
@@ -173,9 +179,10 @@ module AWS
|
|
173
179
|
})
|
174
180
|
end
|
175
181
|
|
176
|
-
# Handler for the ExternalWorkflowExecutionSignaled event.
|
182
|
+
# Handler for the `ExternalWorkflowExecutionSignaled` event.
|
177
183
|
#
|
178
|
-
# @param [Object] event
|
184
|
+
# @param [Object] event
|
185
|
+
# The event instance.
|
179
186
|
#
|
180
187
|
def handle_external_workflow_execution_signaled(event)
|
181
188
|
signal_id = @decision_helper.signal_initiated_event_to_signal_id[event.attributes[:initiated_event_id]]
|
@@ -188,9 +195,10 @@ module AWS
|
|
188
195
|
end
|
189
196
|
end
|
190
197
|
|
191
|
-
# Handler for the SignalExternalWorkflowExecutionFailed event.
|
198
|
+
# Handler for the `SignalExternalWorkflowExecutionFailed` event.
|
192
199
|
#
|
193
|
-
# @param [Object] event
|
200
|
+
# @param [Object] event
|
201
|
+
# The event instance.
|
194
202
|
#
|
195
203
|
def handle_signal_external_workflow_execution_failed(event)
|
196
204
|
handle_event(event, {
|
@@ -205,9 +213,10 @@ module AWS
|
|
205
213
|
})
|
206
214
|
end
|
207
215
|
|
208
|
-
# Handler for the
|
216
|
+
# Handler for the `StartExternalWorkflowExecutionFailed` event.
|
209
217
|
#
|
210
|
-
# @param [Object] event
|
218
|
+
# @param [Object] event
|
219
|
+
# The event instance.
|
211
220
|
#
|
212
221
|
def handle_start_child_workflow_execution_failed(event)
|
213
222
|
handle_event(event, {
|
@@ -225,11 +234,10 @@ module AWS
|
|
225
234
|
end
|
226
235
|
end
|
227
236
|
|
228
|
-
|
229
237
|
# Types and methods related to workflow execution. Extend this to implement a workflow decider.
|
230
238
|
#
|
231
239
|
# @!attribute version
|
232
|
-
# Sets or returns the
|
240
|
+
# Sets or returns the decider version.
|
233
241
|
#
|
234
242
|
# @!attribute options
|
235
243
|
# Sets or returns the {WorkflowOptions} for this decider.
|
@@ -249,10 +257,9 @@ module AWS
|
|
249
257
|
base.send :include, InstanceMethods
|
250
258
|
end
|
251
259
|
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
# @!visibility private
|
260
|
+
# @deprecated Set the entry point with {Workflows#workflow} instead.
|
261
|
+
#
|
262
|
+
# @api private
|
256
263
|
def entry_point(input=nil)
|
257
264
|
if input
|
258
265
|
@entry_point = input
|
@@ -267,10 +274,8 @@ module AWS
|
|
267
274
|
raise "You must set an entry point on the workflow definition"
|
268
275
|
end
|
269
276
|
|
270
|
-
#
|
271
|
-
#
|
272
|
-
# Set the version in the {WorkflowOptions} passed in to the {#workflow} method.
|
273
|
-
# @!visibility private
|
277
|
+
# @deprecated Set the version in the {WorkflowOptions} passed in to the {#workflow} method.
|
278
|
+
# @api private
|
274
279
|
def version(arg = nil)
|
275
280
|
if arg
|
276
281
|
self.workflows.each { |workflow| workflow.version = arg }
|
@@ -321,10 +326,10 @@ module AWS
|
|
321
326
|
end
|
322
327
|
|
323
328
|
|
324
|
-
#
|
329
|
+
# @api private
|
325
330
|
def _options; self.workflows.map(&:options); end
|
326
331
|
|
327
|
-
# Defines a new workflow
|
332
|
+
# Defines a new workflow.
|
328
333
|
#
|
329
334
|
# @param entry_point
|
330
335
|
# The entry point (method) that starts the workflow.
|
@@ -341,7 +346,7 @@ module AWS
|
|
341
346
|
end
|
342
347
|
|
343
348
|
# @return [MethodPair]
|
344
|
-
# A {MethodPair} object
|
349
|
+
# A {MethodPair} object.
|
345
350
|
#
|
346
351
|
def get_state_method(get_state_method = nil, options = {})
|
347
352
|
data_converter = options[:data_converter]
|
@@ -375,7 +380,7 @@ module AWS
|
|
375
380
|
end
|
376
381
|
|
377
382
|
|
378
|
-
# Instance methods for {DecisionContext}
|
383
|
+
# Instance methods for {DecisionContext}.
|
379
384
|
module InstanceMethods
|
380
385
|
|
381
386
|
# Returns the {DecisionContext} instance.
|
@@ -389,7 +394,7 @@ module AWS
|
|
389
394
|
# Returns the workflow ID.
|
390
395
|
#
|
391
396
|
# @return
|
392
|
-
# The workflow ID
|
397
|
+
# The workflow ID.
|
393
398
|
#
|
394
399
|
def workflow_id
|
395
400
|
self.decision_context.workflow_context.decision_task.workflow_execution.workflow_id
|
@@ -451,7 +456,7 @@ module AWS
|
|
451
456
|
# @deprecated
|
452
457
|
# Use {#create_timer_async} instead.
|
453
458
|
#
|
454
|
-
#
|
459
|
+
# @api private
|
455
460
|
def async_create_timer(delay_seconds, &block)
|
456
461
|
task { self.decision_context.workflow_clock.create_timer(delay_seconds, block) }
|
457
462
|
end
|
@@ -482,12 +487,12 @@ module AWS
|
|
482
487
|
continue_as_new_options.input = input
|
483
488
|
end
|
484
489
|
known_workflows = self.class.workflows
|
485
|
-
# If there is only one workflow, we can unambiguously say that we should use that one
|
490
|
+
# If there is only one workflow, we can unambiguously say that we should use that one.
|
486
491
|
|
487
492
|
if known_workflows.length == 1
|
488
493
|
continue_as_new_options.precursors << known_workflows.first.options
|
489
494
|
end
|
490
|
-
# If we can find a name that matches, use that one
|
495
|
+
# If we can find a name that matches, use that one.
|
491
496
|
if continue_as_new_options.execution_method
|
492
497
|
matching_option = self.class.workflows.map(&:options).find {|x| x.execution_method == continue_as_new_options.execution_method }
|
493
498
|
continue_as_new_options.precursors << matching_option unless matching_option.nil?
|
@@ -501,7 +506,7 @@ module AWS
|
|
501
506
|
# without prior notice.
|
502
507
|
# Use {Workflows} instead.
|
503
508
|
#
|
504
|
-
#
|
509
|
+
# @api private
|
505
510
|
module Decider
|
506
511
|
include Workflows
|
507
512
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
end
|
28
28
|
|
29
29
|
|
30
|
-
# The context for a workflow
|
30
|
+
# The context for a workflow.
|
31
31
|
class WorkflowContext
|
32
32
|
|
33
33
|
attr_accessor :continue_as_new_options
|
@@ -37,7 +37,7 @@
|
|
37
37
|
# The {WorkflowClock} for this workflow.
|
38
38
|
attr_accessor :workflow_clock
|
39
39
|
|
40
|
-
# Creates a new `WorkflowContext
|
40
|
+
# Creates a new `WorkflowContext`.
|
41
41
|
#
|
42
42
|
# @param decision_task
|
43
43
|
# The decision task method for this workflow. This is accessible after instance creation by using the
|
@@ -88,7 +88,7 @@ module AWS
|
|
88
88
|
# Creates a new `ChildWorkflowFailedException`
|
89
89
|
#
|
90
90
|
# @param event_id
|
91
|
-
# The event
|
91
|
+
# The event ID for the exception.
|
92
92
|
#
|
93
93
|
# @param execution
|
94
94
|
# The child workflow execution that raised the exception.
|
@@ -112,7 +112,7 @@ module AWS
|
|
112
112
|
|
113
113
|
|
114
114
|
# This exception is used by the framework internally to communicate activity failure. When an activity fails due to
|
115
|
-
# an unhandled exception, it is wrapped in ActivityFailureException and reported to Amazon SWF. You need to deal
|
115
|
+
# an unhandled exception, it is wrapped in {ActivityFailureException} and reported to Amazon SWF. You need to deal
|
116
116
|
# with this exception only if you use the activity worker extensibility points. Your application code will never
|
117
117
|
# need to deal with this exception.
|
118
118
|
#
|
@@ -139,12 +139,12 @@ module AWS
|
|
139
139
|
# This exception is thrown if an activity was timed out by Amazon SWF. This could happen if the activity task could
|
140
140
|
# not be assigned to the worker within the require time period or could not be completed by the worker in the
|
141
141
|
# required time. You can set these timeouts on the activity using the @ActivityRegistrationOptions annotation or
|
142
|
-
# using the ActivitySchedulingOptions parameter when calling the activity method.
|
142
|
+
# using the `ActivitySchedulingOptions` parameter when calling the activity method.
|
143
143
|
#
|
144
144
|
# @abstract An exception raised when the activity task has timed out.
|
145
145
|
class ActivityTaskTimedOutException < ActivityFailureException
|
146
146
|
|
147
|
-
# Creates a new ActivityTaskTimeoutException
|
147
|
+
# Creates a new `ActivityTaskTimeoutException`.
|
148
148
|
def initialize(id, activity_id, reason, details)
|
149
149
|
@id = id
|
150
150
|
@activity_id = activity_id
|
@@ -159,14 +159,14 @@ module AWS
|
|
159
159
|
end
|
160
160
|
|
161
161
|
# Unhandled exceptions in activities are reported back to the workflow implementation by throwing an
|
162
|
-
# `ActivityTaskFailedException`. The original exception can be retrieved from the reason attribute of this
|
162
|
+
# `ActivityTaskFailedException`. The original exception can be retrieved from the `reason` attribute of this
|
163
163
|
# exception. The exception also provides information in the `details` attribute that is useful for debugging
|
164
164
|
# purposes, such as the unique activity identifier in the history.
|
165
165
|
#
|
166
166
|
# @abstract An exception raised when the activity task has failed.
|
167
167
|
class ActivityTaskFailedException < ActivityFailureException
|
168
168
|
attr_accessor :cause, :details
|
169
|
-
# Creates a new ActivityTaskFailedException
|
169
|
+
# Creates a new `ActivityTaskFailedException`.
|
170
170
|
def initialize(id, activity_id, reason, details)
|
171
171
|
@id = id
|
172
172
|
@activity_id = activity_id
|
data/lib/aws/decider/executor.rb
CHANGED
@@ -19,6 +19,7 @@ require 'logger'
|
|
19
19
|
module AWS
|
20
20
|
module Flow
|
21
21
|
|
22
|
+
# @api private
|
22
23
|
class LogMock
|
23
24
|
attr_accessor :log_level
|
24
25
|
def initialize()
|
@@ -39,6 +40,7 @@ module AWS
|
|
39
40
|
end
|
40
41
|
class RejectedExecutionException < Exception; end
|
41
42
|
|
43
|
+
# @api private
|
42
44
|
class ForkingExecutor
|
43
45
|
|
44
46
|
class << self
|
@@ -47,12 +49,12 @@ module AWS
|
|
47
49
|
attr_accessor :max_workers, :pids, :is_shutdown
|
48
50
|
|
49
51
|
def initialize(options = {})
|
50
|
-
@log = options[:logger]
|
51
|
-
|
52
|
+
unless @log = options[:logger]
|
53
|
+
@log = Logger.new("#{Dir.tmpdir}/forking_log")
|
54
|
+
@log.level = options[:log_level] || Logger::ERROR
|
55
|
+
@log.info("LOG INITIALIZED")
|
56
|
+
end
|
52
57
|
@semaphore = Mutex.new
|
53
|
-
log_level = options[:log_level] || 4
|
54
|
-
@log.level = Logger::DEBUG
|
55
|
-
@log.info("LOG INITIALIZED")
|
56
58
|
@max_workers = options[:max_workers] || 1
|
57
59
|
@pids = []
|
58
60
|
@is_shutdown = false
|
@@ -114,6 +116,7 @@ module AWS
|
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
119
|
+
# @api private
|
117
120
|
def block_on_max_workers
|
118
121
|
@log.debug "block_on_max_workers workers=#{@pids.size}, max_workers=#{@max_workers}"
|
119
122
|
if @pids.size >= @max_workers
|
@@ -127,18 +130,19 @@ module AWS
|
|
127
130
|
|
128
131
|
private
|
129
132
|
|
130
|
-
#
|
131
|
-
# Block for at least one child to finish if block argument is set to true
|
133
|
+
# Removes all child processes from @pids list that have finished.
|
134
|
+
# Block for at least one child to finish if block argument is set to `true`.
|
135
|
+
# @api private
|
132
136
|
def remove_completed_pids(block=false)
|
133
137
|
loop do
|
134
138
|
# waitpid2 throws an Errno::ECHILD if there are no child processes,
|
135
|
-
# so we don't even call it if there aren't any pids to wait on
|
139
|
+
# so we don't even call it if there aren't any pids to wait on.
|
136
140
|
break if @pids.empty?
|
137
|
-
#
|
138
|
-
# if the child process has exited
|
141
|
+
# Non-blocking wait only returns a non-null pid
|
142
|
+
# if the child process has exited.
|
139
143
|
pid, status = Process.waitpid2(-1, block ? 0 : Process::WNOHANG)
|
140
144
|
@log.debug "#{pid}"
|
141
|
-
#
|
145
|
+
# No more children have finished.
|
142
146
|
break unless pid
|
143
147
|
|
144
148
|
if status.success?
|
@@ -15,30 +15,61 @@
|
|
15
15
|
|
16
16
|
module AWS
|
17
17
|
module Flow
|
18
|
+
|
19
|
+
# Constants used by the AWS Flow Framework for Ruby.
|
20
|
+
#
|
21
|
+
# @!attribute exponential_retry_maximum_retry_interval_seconds
|
22
|
+
# The maximum exponential retry interval in seconds.
|
23
|
+
#
|
24
|
+
# Use the value `-1` (the default) to set *no maximum*.
|
25
|
+
#
|
26
|
+
# @!attribute exponential_retry_retry_expiration_seconds
|
27
|
+
# The maximum time that can pass, in seconds, before the exponential retry
|
28
|
+
# attempt is considered to be a failure.
|
29
|
+
#
|
30
|
+
# Use the value -1 (the default) to set *no maximum*.
|
31
|
+
#
|
32
|
+
# @!attribute exponential_retry_backoff_coefficient
|
33
|
+
#
|
34
|
+
# The coefficient used to determine how much to back off the interval
|
35
|
+
# timing for an exponential retry scenario. The default value, `2.0`,
|
36
|
+
# causes each retry attempt to wait twice as long as the previous attempt.
|
37
|
+
#
|
38
|
+
# @!attribute exponential_retry_maximum_attempts
|
39
|
+
# The maximum number of attempts to make for an exponential retry of a
|
40
|
+
# failed task. The default value is `Float::INFINITY`, which indicates
|
41
|
+
# that there should be *no* limit to the number of retry attempts.
|
42
|
+
#
|
43
|
+
# @!attribute exponential_retry_function
|
44
|
+
# The default exponential retry function.
|
45
|
+
#
|
46
|
+
# @!attribute default_data_converter
|
47
|
+
# The DataConverter used to interpret results from Amazon SWF. By
|
48
|
+
# default, this is {YAMLDataConverter}.
|
49
|
+
#
|
50
|
+
# @!attribute exponential_retry_exceptions_to_include
|
51
|
+
# A list of the exception types to include for initiating retry attempts.
|
52
|
+
# By default, all exceptions are included (the default value is
|
53
|
+
# `Exception`, which is the base class for all exceptions.)
|
54
|
+
#
|
55
|
+
# @!attribute exponential_retry_exceptions_to_exclude
|
56
|
+
# A list of the exception types to exclude from initiating retry attempts.
|
57
|
+
# By default, no exceptions are excluded; this is an empty list.
|
58
|
+
#
|
59
|
+
# @!attribute jitter_function
|
60
|
+
# The function that is used to determine how long to wait for the next
|
61
|
+
# retry attempt when *should_jitter* is set to `true`.
|
62
|
+
#
|
63
|
+
# @!attribute should_jitter
|
64
|
+
# Indicates whether there should be any randomness built in to the timing of
|
65
|
+
# the retry attempt. The default value is `true`.
|
66
|
+
#
|
18
67
|
class FlowConstants
|
68
|
+
|
19
69
|
class << self
|
20
70
|
attr_reader :exponential_retry_maximum_retry_interval_seconds, :exponential_retry_retry_expiration_seconds, :exponential_retry_backoff_coefficient, :exponential_retry_maximum_attempts, :exponential_retry_function, :default_data_converter, :exponential_retry_exceptions_to_include, :exponential_retry_exceptions_to_exclude, :jitter_function, :should_jitter, :exponential_retry_initial_retry_interval
|
21
|
-
# # The maximum exponential retry interval, in seconds. Use the value -1 (the default) to set <i>no maximum</i>.
|
22
|
-
# attr_reader :exponential_retry_maximum_retry_interval_seconds
|
23
|
-
|
24
|
-
# # The maximum time that can pass, in seconds, before the exponential retry attempt is considered a failure. Use
|
25
|
-
# # the value -1 (the default) to set <i>no maximum</i>.
|
26
|
-
# attr_reader :exponential_retry_retry_expiration_seconds
|
27
|
-
|
28
|
-
# # The coefficient used to determine how much to back off the interval timing for an exponential retry scenario.
|
29
|
-
# # The default value, 2.0, causes each attempt to wait twice as long as the previous attempt.
|
30
|
-
# attr_reader :exponential_retry_backoff_coefficient
|
31
|
-
|
32
|
-
# # The maximum number of attempts to make for an exponential retry of a failed task. The default value is
|
33
|
-
# # Float::INFINITY.
|
34
|
-
# attr_reader :exponential_retry_maximum_attempts
|
35
|
-
|
36
|
-
# # The default exponential retry function.
|
37
|
-
# attr_reader :exponential_retry_function
|
38
|
-
|
39
|
-
# The DataConverter for instances of this class.
|
40
|
-
attr_reader :default_data_converter
|
41
71
|
end
|
72
|
+
|
42
73
|
INFINITY = -1
|
43
74
|
@exponential_retry_maximum_attempts = Float::INFINITY
|
44
75
|
@exponential_retry_maximum_retry_interval_seconds = -1
|
@@ -70,8 +101,9 @@ module AWS
|
|
70
101
|
end
|
71
102
|
|
72
103
|
@jitter_function = lambda do |seed, max_value|
|
73
|
-
|
74
|
-
|
104
|
+
raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0
|
105
|
+
random = Random.new(seed.to_i)
|
106
|
+
random.rand(max_value)
|
75
107
|
end
|
76
108
|
|
77
109
|
@default_data_converter = YAMLDataConverter.new
|