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
- DATA_LIMIT =
32768
- REASON_LIMIT =
Number of chars that can fit in FlowException’s reason
256
- DETAILS_LIMIT =
Number of chars that can fit in FlowException’s details. Same as DATA_LIMIT
DATA_LIMIT
- TRUNCATION_OVERHEAD =
This is the truncation overhead for serialization.
8000
- TRUNCATED =
Truncation string added to the end of a trucated string“
"[TRUNCATED]"
- 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
readonly
The DataConverter used to interpret results from Amazon SWF.
-
#exponential_retry_backoff_coefficient ⇒ Float
readonly
The coefficient used to determine how much to back off the interval timing for an exponential retry scenario.
-
#exponential_retry_exceptions_to_exclude ⇒ Array<Object>
readonly
A list of the exception types to exclude from initiating retry attempts.
-
#exponential_retry_exceptions_to_include ⇒ Array<Class>
readonly
A list of the exception types to include for initiating retry attempts.
-
#exponential_retry_function ⇒ Object
readonly
The default exponential retry function.
-
#exponential_retry_initial_retry_interval ⇒ Fixnum
readonly
The initial retry interval.
-
#exponential_retry_maximum_attempts ⇒ Float
readonly
The maximum number of attempts to make for an exponential retry of a failed task.
-
#exponential_retry_maximum_retry_interval_seconds ⇒ Fixnum
readonly
The maximum interval that can pass, in seconds, before a retry occurs.
-
#exponential_retry_retry_expiration_seconds ⇒ Fixnum
readonly
The maximum time that can pass, in seconds, before an exponential retry attempt is considered to be a failure.
-
#jitter_function ⇒ Object
readonly
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 ⇒ Boolean
readonly
Indicates whether there should be any randomness built in to the timing of the retry attempt.
-
#use_worker_task_list ⇒ String
readonly
Used with activity and workflow options.
Class Attribute Details
.default_data_converter ⇒ Object (readonly)
Returns the value of attribute default_data_converter.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 def default_data_converter @default_data_converter end |
.exponential_retry_backoff_coefficient ⇒ Object (readonly)
Returns the value of attribute exponential_retry_backoff_coefficient.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 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.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 def exponential_retry_retry_expiration_seconds @exponential_retry_retry_expiration_seconds end |
.jitter_function ⇒ Object (readonly)
Returns the value of attribute jitter_function.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 def jitter_function @jitter_function end |
.should_jitter ⇒ Object (readonly)
Returns the value of attribute should_jitter.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 def should_jitter @should_jitter end |
.use_worker_task_list ⇒ Object (readonly)
Returns the value of attribute use_worker_task_list.
96 97 98 |
# File 'lib/aws/decider/flow_defaults.rb', line 96 def use_worker_task_list @use_worker_task_list end |
Instance Attribute Details
#default_data_converter ⇒ Object (readonly)
The DataConverter used to interpret results from Amazon SWF.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Float (readonly)
The coefficient used to determine how much to back off the interval
timing for an exponential retry scenario.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Array<Object> (readonly)
A list of the exception types to exclude from initiating retry attempts.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Array<Class> (readonly)
A list of the exception types to include for initiating retry attempts.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 (readonly)
The default exponential retry function.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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_initial_retry_interval ⇒ Fixnum (readonly)
The initial retry interval.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Float (readonly)
The maximum number of attempts to make for an exponential retry of a
failed task.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Fixnum (readonly)
The maximum interval that can pass, in seconds, before a retry occurs.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Fixnum (readonly)
The maximum time that can pass, in seconds, before an exponential retry
attempt is considered to be a failure.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 (readonly)
The function that is used to determine how long to wait for the next
retry attempt when *should_jitter* is set to `true`.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 ⇒ Boolean (readonly)
Indicates whether there should be any randomness built in to the timing
of the retry attempt.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 |
#use_worker_task_list ⇒ String (readonly)
Used with activity and workflow options. Indicates that the activity
and/or workflow should use the same task list that the associated
worker is polling on.
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/aws/decider/flow_defaults.rb', line 93 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 # Sizes taken from # http://docs.aws.amazon.com/amazonswf/latest/apireference/API_FailWorkflowExecutionDecisionAttributes.html DATA_LIMIT = 32768 # Number of chars that can fit in FlowException's reason REASON_LIMIT = 256 # Number of chars that can fit in FlowException's details. Same as # DATA_LIMIT DETAILS_LIMIT = DATA_LIMIT # This is the truncation overhead for serialization. TRUNCATION_OVERHEAD = 8000 # Truncation string added to the end of a trucated string" TRUNCATED = "[TRUNCATED]" 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 |