Class: AWS::Flow::FlowConstants
- Inherits:
-
Object
- Object
- AWS::Flow::FlowConstants
- Defined in:
- lib/aws/decider/flow_defaults.rb
Overview
Constants used by the AWS Flow Framework for Ruby.
Constant Summary collapse
- INFINITY =
-1
- RETENTION_DEFAULT =
7
- NUM_OF_WORKERS_DEFAULT =
1
Class Attribute Summary collapse
-
.default_data_converter ⇒ Object
readonly
Returns the value of attribute default_data_converter.
-
.exponential_retry_backoff_coefficient ⇒ Object
readonly
Returns the value of attribute exponential_retry_backoff_coefficient.
-
.exponential_retry_exceptions_to_exclude ⇒ Object
readonly
Returns the value of attribute exponential_retry_exceptions_to_exclude.
-
.exponential_retry_exceptions_to_include ⇒ Object
readonly
Returns the value of attribute exponential_retry_exceptions_to_include.
-
.exponential_retry_function ⇒ Object
readonly
Returns the value of attribute exponential_retry_function.
-
.exponential_retry_initial_retry_interval ⇒ Object
readonly
Returns the value of attribute exponential_retry_initial_retry_interval.
-
.exponential_retry_maximum_attempts ⇒ Object
readonly
Returns the value of attribute exponential_retry_maximum_attempts.
-
.exponential_retry_maximum_retry_interval_seconds ⇒ Object
readonly
Returns the value of attribute exponential_retry_maximum_retry_interval_seconds.
-
.exponential_retry_retry_expiration_seconds ⇒ Object
readonly
Returns the value of attribute exponential_retry_retry_expiration_seconds.
-
.jitter_function ⇒ Object
readonly
Returns the value of attribute jitter_function.
-
.should_jitter ⇒ Object
readonly
Returns the value of attribute should_jitter.
-
.use_worker_task_list ⇒ Object
readonly
Returns the value of attribute use_worker_task_list.
Instance Attribute Summary collapse
-
#default_data_converter ⇒ Object
The DataConverter used to interpret results from Amazon SWF.
-
#exponential_retry_backoff_coefficient ⇒ Object
The coefficient used to determine how much to back off the interval timing for an exponential retry scenario.
-
#exponential_retry_exceptions_to_exclude ⇒ Object
A list of the exception types to exclude from initiating retry attempts.
-
#exponential_retry_exceptions_to_include ⇒ Object
A list of the exception types to include for initiating retry attempts.
-
#exponential_retry_function ⇒ Object
The default exponential retry function.
-
#exponential_retry_maximum_attempts ⇒ Object
The maximum number of attempts to make for an exponential retry of a failed task.
-
#exponential_retry_maximum_retry_interval_seconds ⇒ Object
The maximum exponential retry interval in seconds.
-
#exponential_retry_retry_expiration_seconds ⇒ Object
The maximum time that can pass, in seconds, before the exponential retry attempt is considered to be a failure.
-
#jitter_function ⇒ Object
The function that is used to determine how long to wait for the next retry attempt when should_jitter is set to ‘true`.
-
#should_jitter ⇒ Object
Indicates whether there should be any randomness built in to the timing of the retry attempt.
Class Attribute Details
.default_data_converter ⇒ Object (readonly)
Returns the value of attribute default_data_converter.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def default_data_converter @default_data_converter end |
.exponential_retry_backoff_coefficient ⇒ Object (readonly)
Returns the value of attribute exponential_retry_backoff_coefficient.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_backoff_coefficient @exponential_retry_backoff_coefficient end |
.exponential_retry_exceptions_to_exclude ⇒ Object (readonly)
Returns the value of attribute exponential_retry_exceptions_to_exclude.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_exceptions_to_exclude @exponential_retry_exceptions_to_exclude end |
.exponential_retry_exceptions_to_include ⇒ Object (readonly)
Returns the value of attribute exponential_retry_exceptions_to_include.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_exceptions_to_include @exponential_retry_exceptions_to_include end |
.exponential_retry_function ⇒ Object (readonly)
Returns the value of attribute exponential_retry_function.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_function @exponential_retry_function end |
.exponential_retry_initial_retry_interval ⇒ Object (readonly)
Returns the value of attribute exponential_retry_initial_retry_interval.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_initial_retry_interval @exponential_retry_initial_retry_interval end |
.exponential_retry_maximum_attempts ⇒ Object (readonly)
Returns the value of attribute exponential_retry_maximum_attempts.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_maximum_attempts @exponential_retry_maximum_attempts end |
.exponential_retry_maximum_retry_interval_seconds ⇒ Object (readonly)
Returns the value of attribute exponential_retry_maximum_retry_interval_seconds.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_maximum_retry_interval_seconds @exponential_retry_maximum_retry_interval_seconds end |
.exponential_retry_retry_expiration_seconds ⇒ Object (readonly)
Returns the value of attribute exponential_retry_retry_expiration_seconds.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def exponential_retry_retry_expiration_seconds @exponential_retry_retry_expiration_seconds end |
.jitter_function ⇒ Object (readonly)
Returns the value of attribute jitter_function.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def jitter_function @jitter_function end |
.should_jitter ⇒ Object (readonly)
Returns the value of attribute should_jitter.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def should_jitter @should_jitter end |
.use_worker_task_list ⇒ Object (readonly)
Returns the value of attribute use_worker_task_list.
70 71 72 |
# File 'lib/aws/decider/flow_defaults.rb', line 70 def use_worker_task_list @use_worker_task_list end |
Instance Attribute Details
#default_data_converter ⇒ Object
The DataConverter used to interpret results from Amazon SWF. By default, this is YAMLDataConverter.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_backoff_coefficient ⇒ Object
The coefficient used to determine how much to back off the interval timing for an exponential retry scenario. The default value, ‘2.0`, causes each retry attempt to wait twice as long as the previous attempt.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_exceptions_to_exclude ⇒ Object
A list of the exception types to exclude from initiating retry attempts. By default, no exceptions are excluded; this is an empty list.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_exceptions_to_include ⇒ Object
A list of the exception types to include for initiating retry attempts. By default, all exceptions are included (the default value is ‘Exception`, which is the base class for all exceptions.)
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_function ⇒ Object
The default exponential retry function.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_maximum_attempts ⇒ Object
The maximum number of attempts to make for an exponential retry of a failed task. The default value is ‘Float::INFINITY`, which indicates that there should be no limit to the number of retry attempts.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_maximum_retry_interval_seconds ⇒ Object
The maximum exponential retry interval in seconds.
Use the value ‘-1` (the default) to set *no maximum*.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#exponential_retry_retry_expiration_seconds ⇒ Object
The maximum time that can pass, in seconds, before the exponential retry attempt is considered to be a failure.
Use the value -1 (the default) to set *no maximum*.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#jitter_function ⇒ Object
The function that is used to determine how long to wait for the next retry attempt when should_jitter is set to ‘true`.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |
#should_jitter ⇒ Object
Indicates whether there should be any randomness built in to the timing of the retry attempt. The default value is ‘true`.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/decider/flow_defaults.rb', line 67 class FlowConstants class << self 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, :use_worker_task_list end INFINITY = -1 RETENTION_DEFAULT = 7 NUM_OF_WORKERS_DEFAULT = 1 @exponential_retry_maximum_attempts = Float::INFINITY @exponential_retry_maximum_retry_interval_seconds = -1 @exponential_retry_retry_expiration_seconds = -1 @exponential_retry_backoff_coefficient = 2.0 @exponential_retry_initial_retry_interval = 2 @should_jitter = true @exponential_retry_exceptions_to_exclude = [] @exponential_retry_exceptions_to_include = [Exception] @exponential_retry_function = lambda do |first, time_of_failure, attempts, | raise ArgumentError.new("first should be an instance of Time") unless first.instance_of?(Time) raise ArgumentError.new("time_of_failure should be nil or an instance of Time") unless time_of_failure.nil? || time_of_failure.instance_of?(Time) raise ArgumentError.new("number of attempts should be positive") if (attempts.values.find {|x| x < 0}) raise ArgumentError.new("number of attempts should be more than 2") if (attempts.values.reduce(0,:+) < 2) raise ArgumentError.new("user options must be of type ExponentialRetryOptions") unless .is_a? ExponentialRetryOptions # get values from options initial_interval = .initial_retry_interval backoff = .backoff_coefficient max_interval = .maximum_retry_interval_seconds retry_expiration = .retry_expiration_interval_seconds # calculate the initial retry seconds result = initial_interval * (backoff ** (attempts.values.reduce(0, :+) - 2)) # check if the calculated retry seconds is greater than the maximum # retry interval allowed. If it is, then replace it with maximum_retry_interval_seconds result = max_interval if ( !max_interval.nil? && max_interval != INFINITY && result > max_interval) # how much time has elapsed since the first time this task was scheduled time_elapsed = time_of_failure.nil? ? 0 : (time_of_failure - first).to_i # return -1 if retry will expire result = -1 if (! retry_expiration.nil? && retry_expiration != INFINITY && (result + time_elapsed) >= retry_expiration) return result.to_i end @jitter_function = lambda do |seed, max_value| raise ArgumentError.new("max_value should be greater than 0") unless max_value > 0 random = Random.new(seed.to_i) random.rand(max_value) end @default_data_converter = YAMLDataConverter.new @use_worker_task_list = "USE_WORKER_TASK_LIST" end |