Class: AWS::Flow::FlowConstants

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/decider/flow_defaults.rb

Overview

Constants used by the AWS Flow Framework for Ruby.

Constant Summary collapse

INFINITY =
-1

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Attribute Details

.default_data_converterObject (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_coefficientObject (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_excludeObject (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_includeObject (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_functionObject (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_intervalObject (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_attemptsObject (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_secondsObject (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_secondsObject (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_functionObject (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_jitterObject (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

Instance Attribute Details

#default_data_converterObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_backoff_coefficientObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_exceptions_to_excludeObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_exceptions_to_includeObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_functionObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_maximum_attemptsObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_maximum_retry_interval_secondsObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#exponential_retry_retry_expiration_secondsObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#jitter_functionObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end

#should_jitterObject

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
# 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
  end

  INFINITY = -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, options|

    raise ArgumentError.new("first is not an instance of Time") unless first.instance_of?(Time)
    raise ArgumentError.new("time_of_failure can't be negative") if time_of_failure < 0
    raise ArgumentError.new("number of attempts can't be negative") 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 options.is_a? ExponentialRetryOptions

    initial_retry_interval = options.initial_retry_interval
    backoff_coefficient = options.backoff_coefficient
    maximum_retry_interval_seconds = options.maximum_retry_interval_seconds
    retry_expiration_interval_seconds = options.retry_expiration_interval_seconds
    result = initial_retry_interval * (backoff_coefficient ** (attempts.values.reduce(0, :+) - 2))
    result = maximum_retry_interval_seconds if (! maximum_retry_interval_seconds.nil? && maximum_retry_interval_seconds != INFINITY && result > maximum_retry_interval_seconds)
    seconds_since_first_attempt = time_of_failure.zero? ? 0 : -(first - time_of_failure).to_i
    result = -1 if (! retry_expiration_interval_seconds.nil? &&
                    retry_expiration_interval_seconds != INFINITY &&
                    (result + seconds_since_first_attempt) >= retry_expiration_interval_seconds)
    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
end