aws-flow 1.1.1 → 1.2.0
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 +8 -8
- data/lib/aws/decider/decider.rb +1 -1
- data/lib/aws/decider/executor.rb +36 -30
- data/lib/aws/decider/options.rb +178 -120
- data/lib/aws/decider/task_handler.rb +5 -7
- data/lib/aws/decider/task_poller.rb +49 -34
- data/lib/aws/decider/utilities.rb +13 -3
- data/lib/aws/decider/version.rb +1 -1
- data/lib/aws/decider/worker.rb +137 -40
- data/lib/aws/decider/workflow_client.rb +1 -1
- data/spec/aws/integration/integration_spec.rb +55 -33
- data/spec/aws/unit/decider_spec.rb +22 -19
- data/spec/aws/unit/executor_spec.rb +49 -0
- data/spec/aws/unit/options_spec.rb +293 -0
- data/spec/aws/unit/preinclude_tests.rb +2 -1
- data/spec/spec_helper.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODBhMDgxOTcxNDAyNGUzMzZmMDllMDdjMWRiZmE3ZjZmM2NmOTA3MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDhmNDA5OTBhNThkNDhmMGQ4MjM2ZDcyMGJhM2U1YTNlMGZiYzkyNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTRlNDUxZDIyZjQyNGRhNzAyOTZhZmQ0NjkwNjI0NThmZGIwOTJmYWVlN2Y3
|
10
|
+
ODY2MGZiZjFmOWE4MGJjN2VhNzJkNzBkMjhiYmNmYmNlMTExNjg3NTlkZjRm
|
11
|
+
YzlmZGQ3MjE5MWEyM2I2YjEyYmZiN2NmOGY2YTllMDY0MzE4YTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTczMTcwODZmMWZkNTgxODQ2NTZjY2FjNmE4ZGRiY2I5NzA0OWVhNTcxY2Ey
|
14
|
+
OThhNGI3ZDY2MDM2ZmM1ZmQ3M2QyZTcyN2JkZGYzNDlkYjM4NjVlMjA1NTMw
|
15
|
+
N2VhMjllYTRhYTE5M2E4M2FhNGZlMGY2ZjEzYjdjMzI4NjFkZmE=
|
data/lib/aws/decider/decider.rb
CHANGED
@@ -338,7 +338,7 @@ module AWS
|
|
338
338
|
# A block of {WorkflowOptions} for the workflow.
|
339
339
|
#
|
340
340
|
def workflow(entry_point, &block)
|
341
|
-
options = Utilities::interpret_block_for_options(
|
341
|
+
options = Utilities::interpret_block_for_options(WorkflowOptions, block)
|
342
342
|
options.execution_method = entry_point
|
343
343
|
workflow_name = options.prefix_name || self.to_s
|
344
344
|
workflow_type = WorkflowType.new(workflow_name.to_s + "." + entry_point.to_s, options.version, options)
|
data/lib/aws/decider/executor.rb
CHANGED
@@ -50,9 +50,7 @@ module AWS
|
|
50
50
|
|
51
51
|
def initialize(options = {})
|
52
52
|
unless @log = options[:logger]
|
53
|
-
@log =
|
54
|
-
@log.level = options[:log_level] || Logger::ERROR
|
55
|
-
@log.info("LOG INITIALIZED")
|
53
|
+
@log = Utilities::LogFactory.make_logger(self)
|
56
54
|
end
|
57
55
|
@semaphore = Mutex.new
|
58
56
|
@max_workers = options[:max_workers] || 1
|
@@ -63,38 +61,38 @@ module AWS
|
|
63
61
|
end
|
64
62
|
|
65
63
|
def execute(&block)
|
66
|
-
@log.
|
64
|
+
@log.debug "Currently running pids: #{@pids}"
|
67
65
|
raise RejectedExecutionException if @is_shutdown
|
68
66
|
block_on_max_workers
|
69
|
-
@log.debug "
|
67
|
+
@log.debug "Creating a new child process: parent=#{Process.pid}"
|
70
68
|
child_pid = fork do
|
71
69
|
begin
|
72
|
-
@log.debug "
|
70
|
+
@log.debug "Inside the new child process: parent=#{Process.ppid}, child_pid=#{Process.pid}"
|
73
71
|
# TODO: which signals to ignore?
|
74
72
|
# ignore signals in the child
|
75
73
|
%w{ TERM INT HUP SIGUSR2 }.each { |signal| Signal.trap(signal, 'SIG_IGN') }
|
74
|
+
@log.debug "Executing block from child process: parent=#{Process.ppid}, child_pid=#{Process.pid}"
|
76
75
|
block.call
|
77
|
-
@log.debug "
|
76
|
+
@log.debug "Exiting from child process: parent=#{Process.ppid}, child_pid=#{Process.pid}"
|
78
77
|
Process.exit!(0)
|
79
78
|
rescue => e
|
80
|
-
@log.error e
|
81
|
-
@log.error "Definitely dying off right here"
|
79
|
+
@log.error "child_pid=#{Process.pid} failed while executing the task: #{e}. Exiting: parent=#{Process.ppid}, child_pid=#{Process.pid}"
|
82
80
|
Process.exit!(1)
|
83
81
|
end
|
84
82
|
end
|
85
|
-
@log.debug "
|
83
|
+
@log.debug "Created a new child process: parent=#{Process.pid}, child_pid=#{child_pid}"
|
86
84
|
@pids << child_pid
|
87
85
|
end
|
88
86
|
|
89
87
|
def shutdown(timeout_seconds)
|
88
|
+
@log.debug "Shutdown requested. Currently running pids: #{@pids}"
|
90
89
|
@is_shutdown = true
|
91
90
|
remove_completed_pids
|
92
91
|
|
93
92
|
unless @pids.empty?
|
94
|
-
|
95
|
-
|
96
|
-
#
|
97
|
-
# their work. This allows us to handle graceful shutdown of workers.
|
93
|
+
# If the timeout_seconds value is set to Float::INFINITY, it will wait
|
94
|
+
# indefinitely till all workers finish their work. This allows us to
|
95
|
+
# handle graceful shutdown of workers.
|
98
96
|
if timeout_seconds == Float::INFINITY
|
99
97
|
@log.info "Exit requested, waiting indefinitely till all child processes finish"
|
100
98
|
remove_completed_pids true while !@pids.empty?
|
@@ -110,7 +108,7 @@ module AWS
|
|
110
108
|
|
111
109
|
# forcibly kill all remaining children
|
112
110
|
unless @pids.empty?
|
113
|
-
@log.warn "Child processes still running, sending KILL signal: #{@pids.join(',')}"
|
111
|
+
@log.warn "Child processes #{@pids} still running, sending KILL signal: #{@pids.join(',')}"
|
114
112
|
@pids.each { |pid| Process.kill('KILL', pid) }
|
115
113
|
end
|
116
114
|
end
|
@@ -120,44 +118,52 @@ module AWS
|
|
120
118
|
def block_on_max_workers
|
121
119
|
@log.debug "block_on_max_workers workers=#{@pids.size}, max_workers=#{@max_workers}"
|
122
120
|
if @pids.size >= @max_workers
|
123
|
-
@log.info "Reached maximum number of workers (#{@max_workers}),
|
124
|
-
waiting for some to finish"
|
121
|
+
@log.info "Reached maximum number of workers (#{@max_workers}), waiting for some to finish"
|
125
122
|
begin
|
126
123
|
remove_completed_pids(true)
|
127
124
|
end while @pids.size >= @max_workers
|
128
125
|
end
|
126
|
+
@log.debug "Available workers: #{@max_workers - @pids.size} out of #{@max_workers}"
|
129
127
|
end
|
130
128
|
|
131
129
|
private
|
132
130
|
|
133
131
|
# 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
|
132
|
+
# Block for at least one child to finish if block argument is set to
|
133
|
+
# `true`.
|
135
134
|
# @api private
|
136
135
|
def remove_completed_pids(block=false)
|
136
|
+
@log.debug "Removing completed child processes"
|
137
137
|
loop do
|
138
138
|
# waitpid2 throws an Errno::ECHILD if there are no child processes,
|
139
139
|
# so we don't even call it if there aren't any pids to wait on.
|
140
140
|
break if @pids.empty?
|
141
|
+
@log.debug "Current child processes: #{@pids}"
|
141
142
|
# Non-blocking wait only returns a non-null pid
|
142
143
|
# if the child process has exited.
|
143
144
|
pid, status = Process.waitpid2(-1, block ? 0 : Process::WNOHANG)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
|
146
|
+
if pid
|
147
|
+
# We have something to reap
|
148
|
+
@log.debug "Reaping child process=#{pid}"
|
149
|
+
if status.success?
|
150
|
+
@log.debug "Child process #{pid} exited successfully"
|
151
|
+
else
|
152
|
+
@log.error "Child process #{pid} exited with non-zero status code"
|
153
|
+
end
|
154
|
+
# Delete the pid from the list
|
155
|
+
@pids.delete(pid)
|
156
|
+
# Contract is to block only once if block=true. If we are in this code branch and if block=true, it
|
157
|
+
# means we have already blocked once above, hence it is safe to exit now
|
158
|
+
break if block
|
150
159
|
else
|
151
|
-
|
160
|
+
# Nothing to reap, exit
|
161
|
+
break
|
152
162
|
end
|
153
|
-
|
154
|
-
break if pid
|
163
|
+
|
155
164
|
end
|
156
165
|
end
|
157
166
|
|
158
|
-
|
159
|
-
|
160
167
|
end
|
161
|
-
|
162
168
|
end
|
163
169
|
end
|
data/lib/aws/decider/options.rb
CHANGED
@@ -25,6 +25,69 @@ module AWS
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
# This module refactors out some of the common methods for the Options
|
29
|
+
# classes. Any class including this module should implement
|
30
|
+
# make_runtime_key method and default_keys method. default_keys method
|
31
|
+
# provides an array of keys that are considered to be the default options
|
32
|
+
# for that class. make_runtime_key method converts a passed in default key
|
33
|
+
# to it's corresponding runtime key.
|
34
|
+
module OptionsMethods
|
35
|
+
|
36
|
+
# Retrieves the runtime values for the default options
|
37
|
+
#
|
38
|
+
# @return [Hash]
|
39
|
+
# The runtime option names and their current values.
|
40
|
+
#
|
41
|
+
def get_runtime_options
|
42
|
+
runtime_options = {}
|
43
|
+
# For the default values that are present, convert the default keys into
|
44
|
+
# runtime keys. i.e. remove 'default_' and 'default_task_' from the key
|
45
|
+
# name and merge their values with the default values
|
46
|
+
get_default_options.each do |key, val|
|
47
|
+
new_key = make_runtime_key(key)
|
48
|
+
new_val = get_options([new_key])
|
49
|
+
runtime_options[new_key] = new_val.empty? ? val : new_val.values.first
|
50
|
+
end
|
51
|
+
runtime_options
|
52
|
+
end
|
53
|
+
|
54
|
+
# Retrieves the default options.
|
55
|
+
#
|
56
|
+
# @return [Hash]
|
57
|
+
# A hash containing the default option names and their current values.
|
58
|
+
#
|
59
|
+
def get_default_options
|
60
|
+
# Get the default options
|
61
|
+
get_options(default_keys)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Retrieves full options. It merges the runtime options with the remaining
|
65
|
+
# options
|
66
|
+
#
|
67
|
+
# @return [Hash]
|
68
|
+
# A hash containing the full option names and their current values.
|
69
|
+
#
|
70
|
+
def get_full_options
|
71
|
+
# Initialize an empty hash
|
72
|
+
options_hash = {}
|
73
|
+
|
74
|
+
# Get all the properties held by this class
|
75
|
+
options_keys = self.class.held_properties
|
76
|
+
|
77
|
+
# Remove the unnecessary options (i.e. options not recognized by swf but
|
78
|
+
# only by flow) from the options_keys array.
|
79
|
+
default_keys.concat([:from_class]).each { |x| options_keys.delete(x) }
|
80
|
+
|
81
|
+
# If the value for an option is held by the class, get it and store it
|
82
|
+
# in a hash
|
83
|
+
options_keys.each do |option|
|
84
|
+
options_hash[option] = self.send(option) if self.send(option)
|
85
|
+
end
|
86
|
+
# Merge the options_hash with the runtime options
|
87
|
+
options_hash.merge(self.get_runtime_options)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
28
91
|
# The base class for all options classes in the AWS Flow Framework for Ruby.
|
29
92
|
class Options
|
30
93
|
extend Utilities::UpwardLookups
|
@@ -40,7 +103,9 @@ module AWS
|
|
40
103
|
def self.inherited(child)
|
41
104
|
child.precursors ||= []
|
42
105
|
default_classes = child.ancestors.map do |precursor|
|
43
|
-
|
106
|
+
if precursor.methods.map(&:to_sym).include? :default_classes
|
107
|
+
precursor.default_classes
|
108
|
+
end
|
44
109
|
end.compact.flatten
|
45
110
|
child.instance_variable_set("@default_classes", default_classes)
|
46
111
|
end
|
@@ -69,8 +134,15 @@ module AWS
|
|
69
134
|
#
|
70
135
|
def get_options(options, extra_to_add = {})
|
71
136
|
options = self.class.held_properties.compact if options.empty?
|
72
|
-
|
73
|
-
|
137
|
+
|
138
|
+
set_options = options.select do |option|
|
139
|
+
self.send(option) != nil && self.send(option) != ""
|
140
|
+
end
|
141
|
+
|
142
|
+
option_values = set_options.map do |option|
|
143
|
+
self.send(option) == Float::INFINITY ? "NONE" : self.send(option)
|
144
|
+
end
|
145
|
+
|
74
146
|
result = Hash[set_options.zip(option_values)]
|
75
147
|
result.merge(extra_to_add)
|
76
148
|
end
|
@@ -280,17 +352,19 @@ module AWS
|
|
280
352
|
end
|
281
353
|
end
|
282
354
|
|
283
|
-
# Exponential retry options for the {ActivityClient#exponential_retry}
|
355
|
+
# Exponential retry options for the {ActivityClient#exponential_retry}
|
356
|
+
# method.
|
284
357
|
class ExponentialRetryOptions < RetryOptions
|
285
358
|
default_classes << RetryDefaults.new
|
286
359
|
|
287
|
-
# The backoff coefficient to use. This is a floating point value that is
|
288
|
-
# interval after every retry attempt.
|
289
|
-
#
|
360
|
+
# The backoff coefficient to use. This is a floating point value that is
|
361
|
+
# multiplied with the current retry interval after every retry attempt.
|
362
|
+
# The default value is `2.0`, which means that each retry will take twice
|
363
|
+
# as long as the previous one.
|
290
364
|
property(:backoff_coefficient, [lambda(&:to_i)])
|
291
365
|
|
292
|
-
# The retry expiration interval, in seconds. This will be increased after
|
293
|
-
# provided in `backoff_coefficient`.
|
366
|
+
# The retry expiration interval, in seconds. This will be increased after
|
367
|
+
# every retry attempt by the factor provided in `backoff_coefficient`.
|
294
368
|
property(:retry_expiration_interval_seconds, [lambda(&:to_i)])
|
295
369
|
|
296
370
|
# @api private
|
@@ -306,10 +380,10 @@ module AWS
|
|
306
380
|
|
307
381
|
# The default task start-to-close timeout duration. The default value is
|
308
382
|
# `30`.
|
309
|
-
def
|
383
|
+
def default_task_start_to_close_timeout; 30; end
|
310
384
|
|
311
385
|
# The default child workflow policy. The default value is `TERMINATE`.
|
312
|
-
def
|
386
|
+
def default_child_policy; "TERMINATE"; end
|
313
387
|
|
314
388
|
# Returns a list of tags for the workflow. The default value is an empty
|
315
389
|
# array (no tags).
|
@@ -411,44 +485,47 @@ module AWS
|
|
411
485
|
# * It must not contain the literal string "arn".
|
412
486
|
#
|
413
487
|
class WorkflowOptions < Options
|
414
|
-
|
488
|
+
include OptionsMethods
|
489
|
+
|
490
|
+
properties(
|
491
|
+
:version,
|
492
|
+
:input,
|
493
|
+
:workflow_id,
|
494
|
+
:execution_start_to_close_timeout,
|
495
|
+
:task_start_to_close_timeout,
|
496
|
+
:task_list,
|
497
|
+
:execution_method
|
498
|
+
)
|
499
|
+
|
500
|
+
# Adding default properties
|
501
|
+
properties(
|
502
|
+
:default_task_start_to_close_timeout,
|
503
|
+
:default_execution_start_to_close_timeout,
|
504
|
+
:default_task_list
|
505
|
+
)
|
506
|
+
property(:default_child_policy, [lambda(&:to_s), lambda(&:upcase)])
|
507
|
+
|
508
|
+
|
415
509
|
property(:tag_list, [])
|
416
510
|
property(:child_policy, [lambda(&:to_s), lambda(&:upcase)])
|
417
511
|
property(:data_converter, [])
|
512
|
+
|
418
513
|
default_classes << WorkflowDefaults.new
|
419
514
|
|
420
|
-
#
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
515
|
+
# This method provides the default option keys for workflows
|
516
|
+
def default_keys
|
517
|
+
[:default_task_start_to_close_timeout,
|
518
|
+
:default_execution_start_to_close_timeout,
|
519
|
+
:default_task_list,
|
520
|
+
:default_child_policy]
|
521
|
+
end
|
522
|
+
|
523
|
+
# This method converts default option keys to runtime keys by replacing
|
524
|
+
# "default_" in the key name
|
525
|
+
def make_runtime_key(key)
|
526
|
+
key.to_s.gsub(/default_/, "").to_sym
|
432
527
|
end
|
433
|
-
end
|
434
528
|
|
435
|
-
# Provides the set of workflow options along with defaults.
|
436
|
-
#
|
437
|
-
# @!attribute default_task_start_to_close_timeout
|
438
|
-
# (see WorkflowDefaults#task_start_to_close_timeout)
|
439
|
-
#
|
440
|
-
# @!attribute default_execution_start_to_close_timeout
|
441
|
-
# (see WorkflowDefaults#execution_start_to_close_timeout)
|
442
|
-
#
|
443
|
-
# @!attribute default_task_list
|
444
|
-
# (see WorkflowOptions#task_list)
|
445
|
-
#
|
446
|
-
# @!attribute default_child_policy
|
447
|
-
# (see WorkflowDefaults#child_policy)
|
448
|
-
#
|
449
|
-
class WorkflowOptionsWithDefaults < WorkflowOptions
|
450
|
-
properties(:default_task_start_to_close_timeout, :default_execution_start_to_close_timeout, :default_task_list)
|
451
|
-
property(:default_child_policy, [lambda(&:to_s), lambda(&:upcase)])
|
452
529
|
end
|
453
530
|
|
454
531
|
# Options for {WorkflowClient#start_execution}.
|
@@ -473,6 +550,14 @@ module AWS
|
|
473
550
|
# Defaults for the {ActivityOptions} class.
|
474
551
|
class ActivityDefaults < Defaults
|
475
552
|
|
553
|
+
# The default schedule-to-start timeout for activity tasks. This timeout
|
554
|
+
# represents the time, in seconds, between when the activity task is first
|
555
|
+
# scheduled to when it is started.
|
556
|
+
#
|
557
|
+
# This default can be overridden when scheduling an activity task. You can
|
558
|
+
# set this value to "NONE" to imply no timeout value.
|
559
|
+
def default_task_schedule_to_start_timeout; Float::INFINITY; end
|
560
|
+
|
476
561
|
# The default schedule-to-close timeout for activity tasks. This timeout
|
477
562
|
# represents the time, in seconds, between when the activity task is first
|
478
563
|
# scheduled to when it is closed (whether due to success, failure, or a
|
@@ -480,9 +565,17 @@ module AWS
|
|
480
565
|
#
|
481
566
|
# This default can be overridden when scheduling an activity task. You can
|
482
567
|
# set this value to "NONE" to imply no timeout value.
|
483
|
-
#
|
484
568
|
def default_task_schedule_to_close_timeout; Float::INFINITY; end
|
485
569
|
|
570
|
+
# The default start-to-close timeout for activity tasks. This timeout
|
571
|
+
# represents the time, in seconds, between when the activity task is first
|
572
|
+
# started to when it is closed (whether due to success, failure, or a
|
573
|
+
# timeout).
|
574
|
+
#
|
575
|
+
# This default can be overridden when scheduling an activity task. You can
|
576
|
+
# set this value to "NONE" to imply no timeout value.
|
577
|
+
def default_task_start_to_close_timeout; Float::INFINITY; end
|
578
|
+
|
486
579
|
# The default maximum time, in seconds, before which a worker processing a
|
487
580
|
# task of this type must report progress. If the timeout is exceeded, the
|
488
581
|
# activity task is automatically timed out. If the worker subsequently
|
@@ -490,34 +583,14 @@ module AWS
|
|
490
583
|
#
|
491
584
|
# This default can be overridden when scheduling an activity task. You can
|
492
585
|
# set this value to "NONE" to imply no timeout value.
|
493
|
-
#
|
494
586
|
def default_task_heartbeat_timeout; Float::INFINITY; end
|
495
587
|
|
496
|
-
# The default schedule-to-close timeout. This timeout represents the time
|
497
|
-
# between when the activity task is first scheduled to when it is closed
|
498
|
-
# (whether due to success, failure, or a timeout).
|
499
|
-
#
|
500
|
-
# This default can be overridden when scheduling an activity task. You can
|
501
|
-
# set this value to "NONE" to imply no timeout value.
|
502
|
-
#
|
503
|
-
def schedule_to_close_timeout; Float::INFINITY; end
|
504
|
-
|
505
|
-
# The default maximum time before which a worker processing a task of this
|
506
|
-
# type must report progress. If the timeout is exceeded, the activity task
|
507
|
-
# is automatically timed out. If the worker subsequently attempts to
|
508
|
-
# record a heartbeat or returns a result, it will be ignored. This default
|
509
|
-
# can be overridden when scheduling an activity task.
|
510
|
-
#
|
511
|
-
# This default can be overridden when scheduling an activity task. You can
|
512
|
-
# set this value to "NONE" to imply no timeout value.
|
513
|
-
#
|
514
|
-
def heartbeat_timeout; Float::INFINITY; end
|
515
|
-
|
516
588
|
def data_converter; FlowConstants.default_data_converter; end
|
517
589
|
end
|
518
590
|
|
519
591
|
|
520
|
-
# Options to use on an activity or decider. The following options are
|
592
|
+
# Options to use on an activity or decider. The following options are
|
593
|
+
# defined:
|
521
594
|
#
|
522
595
|
# @!attribute default_task_heartbeat_timeout
|
523
596
|
# The optional default maximum time, specified when registering the
|
@@ -567,16 +640,52 @@ module AWS
|
|
567
640
|
# decision.
|
568
641
|
#
|
569
642
|
class ActivityOptions < Options
|
643
|
+
include OptionsMethods
|
644
|
+
|
645
|
+
properties(
|
646
|
+
:heartbeat_timeout,
|
647
|
+
:task_list,
|
648
|
+
:schedule_to_close_timeout,
|
649
|
+
:schedule_to_start_timeout,
|
650
|
+
:start_to_close_timeout,
|
651
|
+
:version,
|
652
|
+
:input
|
653
|
+
)
|
654
|
+
|
655
|
+
# Adding default properties
|
656
|
+
properties(
|
657
|
+
:default_task_heartbeat_timeout,
|
658
|
+
:default_task_list,
|
659
|
+
:default_task_schedule_to_close_timeout,
|
660
|
+
:default_task_schedule_to_start_timeout,
|
661
|
+
:default_task_start_to_close_timeout,
|
662
|
+
)
|
570
663
|
|
571
|
-
class << self
|
572
|
-
attr_reader :default_options, :runtime_options
|
573
|
-
end
|
574
|
-
properties(:default_task_heartbeat_timeout, :default_task_list, :default_task_schedule_to_close_timeout, :default_task_schedule_to_start_timeout, :default_task_start_to_close_timeout, :heartbeat_timeout, :task_list, :schedule_to_close_timeout, :schedule_to_start_timeout, :start_to_close_timeout, :version, :input)
|
575
664
|
property(:manual_completion, [lambda {|x| x == true}])
|
576
665
|
property(:data_converter, [])
|
577
666
|
|
578
667
|
default_classes << ActivityDefaults.new
|
579
668
|
|
669
|
+
# This method provides the default option keys for activities
|
670
|
+
def default_keys
|
671
|
+
[:default_task_heartbeat_timeout,
|
672
|
+
:default_task_schedule_to_close_timeout,
|
673
|
+
:default_task_schedule_to_start_timeout,
|
674
|
+
:default_task_start_to_close_timeout,
|
675
|
+
:default_task_list]
|
676
|
+
end
|
677
|
+
|
678
|
+
# This method converts default option keys to runtime keys by replacing
|
679
|
+
# "default_task_" in the key name. It handles the exception of task_list
|
680
|
+
# where only "default_" needs to be replaced.
|
681
|
+
def make_runtime_key(key)
|
682
|
+
if key =~ /task_list/
|
683
|
+
key.to_s.gsub(/default_/, "").to_sym
|
684
|
+
else
|
685
|
+
key.to_s.gsub(/default_task_/, "").to_sym
|
686
|
+
end
|
687
|
+
end
|
688
|
+
|
580
689
|
# Gets the activity prefix name.
|
581
690
|
#
|
582
691
|
# @return [String]
|
@@ -657,28 +766,6 @@ module AWS
|
|
657
766
|
super(default_options, use_defaults)
|
658
767
|
end
|
659
768
|
|
660
|
-
# Retrieves the runtime options for this activity. The runtime options returned are:
|
661
|
-
#
|
662
|
-
# * :heartbeat_timeout
|
663
|
-
# * :task_list
|
664
|
-
# * :schedule_to_close_timeout
|
665
|
-
# * :schedule_to_start_timeout
|
666
|
-
# * :start_to_close_timeout
|
667
|
-
#
|
668
|
-
# For a description of each of these options, see {#initialize}.
|
669
|
-
#
|
670
|
-
# @return [Hash]
|
671
|
-
# The runtime option names and their current values.
|
672
|
-
#
|
673
|
-
def get_runtime_options
|
674
|
-
result = get_options([:heartbeat_timeout, :task_list, :schedule_to_close_timeout, :schedule_to_start_timeout, :start_to_close_timeout])
|
675
|
-
default_options = get_options([:default_task_heartbeat_timeout, :default_task_schedule_to_close_timeout, :default_task_schedule_to_start_timeout, :default_task_start_to_close_timeout])
|
676
|
-
default_option_keys, default_option_values = default_options.keys, default_options.values
|
677
|
-
default_option_keys.map! { |option| option.to_s.gsub(/default_task_/, "").to_sym }
|
678
|
-
default_hash = Hash[default_option_keys.zip(default_option_values)]
|
679
|
-
default_hash.merge(result)
|
680
|
-
end
|
681
|
-
|
682
769
|
property(:_exponential_retry, [])
|
683
770
|
|
684
771
|
# Retries the supplied block with exponential retry logic.
|
@@ -690,35 +777,6 @@ module AWS
|
|
690
777
|
retry_options = Utilities::interpret_block_for_options(ExponentialRetryOptions, block)
|
691
778
|
@_exponential_retry = retry_options
|
692
779
|
end
|
693
|
-
|
694
|
-
# Retrieves the runtime options for this activity.
|
695
|
-
#
|
696
|
-
# @return [Hash]
|
697
|
-
# A hash containing the runtime option names and their current values.
|
698
|
-
#
|
699
|
-
def get_full_options
|
700
|
-
options_hash = self.get_runtime_options
|
701
|
-
[:task_list, :version, :_exponential_retry, :prefix_name, :return_on_start, :manual_completion, :data_converter].each do |attribute|
|
702
|
-
options_hash.merge!(attribute => self.send(attribute)) if self.send(attribute)
|
703
|
-
end
|
704
|
-
options_hash
|
705
|
-
end
|
706
|
-
|
707
|
-
# Retrieves the default options for this activity.
|
708
|
-
#
|
709
|
-
# @return [Hash]
|
710
|
-
# A hash containing the default option names and their current values.
|
711
|
-
#
|
712
|
-
# The options retrieved are:
|
713
|
-
#
|
714
|
-
# * :default_task_heartbeat_timeout
|
715
|
-
# * :default_task_schedule_to_close_timeout
|
716
|
-
# * :default_task_schedule_to_start_timeout
|
717
|
-
# * :default_task_start_to_close_timeout
|
718
|
-
#
|
719
|
-
def get_default_options
|
720
|
-
get_options([:default_task_heartbeat_timeout, :default_task_schedule_to_close_timeout, :default_task_schedule_to_start_timeout, :default_task_start_to_close_timeout])
|
721
|
-
end
|
722
780
|
end
|
723
781
|
|
724
782
|
# Runtime options for an activity.
|