Class: Aws::Plugins::RetryErrors Private

Inherits:
Seahorse::Client::Plugin show all
Defined in:
lib/aws-sdk-core/plugins/retry_errors.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Handler, LegacyHandler

Constant Summary collapse

EQUAL_JITTER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

BEGIN LEGACY OPTIONS

->(delay) { (delay / 2) + Kernel.rand(0..(delay / 2)) }
FULL_JITTER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

->(delay) { Kernel.rand(0..delay) }
NO_JITTER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

->(delay) { delay }
JITTERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  none: NO_JITTER,
  equal: EQUAL_JITTER,
  full: FULL_JITTER
}
DEFAULT_BACKOFF =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

lambda do |c|
  delay = 2**c.retries * c.config.retry_base_delay
  if (c.config.retry_max_delay || 0) > 0
    delay = [delay, c.config.retry_max_delay].min
  end
  jitter = c.config.retry_jitter
  jitter = JITTERS[jitter] if jitter.is_a?(Symbol)
  delay = jitter.call(delay) if jitter
  Kernel.sleep(delay)
end
DYNAMODB_SERVICES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Set['DynamoDB', 'DynamoDB Streams'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Plugin

#add_options, #after_initialize, after_initialize, after_initialize_hooks, #before_initialize, before_initialize, before_initialize_hooks, handlers, literal, option, options

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response, #handler_for, #new_handler

Class Method Details

.default_max_attempts(cfg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



214
215
216
217
218
219
220
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 214

def default_max_attempts(cfg)
  # TODO: Remove gate and keep only the new retries branch
  return 3 unless new_retries?

  service_id = cfg.api.['serviceId'] if cfg.respond_to?(:api)
  DYNAMODB_SERVICES.include?(service_id) ? 4 : 3
end

.new_retries?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: Remove this gate and hardcode new retry behavior once AWS_NEW_RETRIES_2026 is enabled by default, which includes:

  • Default retry_mode to ‘standard’

  • Default max_attempts to 4 for DynamoDB

  • Remove the old retries branch in Handler#call

  • Remove the old retries branch in #exponential_backoff

  • Remove LEGACY_RETRY_COST and TIMEOUT_RETRY_COST from RetryQuota

Returns:

  • (Boolean)


174
175
176
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 174

def new_retries?
  ENV.fetch('AWS_NEW_RETRIES_2026', 'false').downcase == 'true'
end

.resolve_adaptive_retry_wait_to_fill(cfg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 222

def resolve_adaptive_retry_wait_to_fill(cfg)
  value = ENV['AWS_ADAPTIVE_RETRY_WAIT_TO_FILL'] ||
          Aws.shared_config.adaptive_retry_wait_to_fill(profile: cfg.profile) ||
          'true'
  # Raise if provided value is not true or false
  if value != 'true' && value != 'false'
    raise ArgumentError,
          'Must provide either `true` or `false` for '\
            'adaptive_retry_wait_to_fill profile option or for '\
            'ENV[\'AWS_ADAPTIVE_RETRY_WAIT_TO_FILL\']'
  end
  value == 'true'
end

.resolve_correct_clock_skew(cfg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 236

def resolve_correct_clock_skew(cfg)
  value = ENV['AWS_CORRECT_CLOCK_SKEW'] ||
          Aws.shared_config.correct_clock_skew(profile: cfg.profile) ||
          'true'
  # Raise if provided value is not true or false
  if value != 'true' && value != 'false'
    raise ArgumentError,
          'Must provide either `true` or `false` for '\
            'correct_clock_skew profile option or for '\
            'ENV[\'AWS_CORRECT_CLOCK_SKEW\']'
  end
  value == 'true'
end

.resolve_max_attempts(cfg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 197

def resolve_max_attempts(cfg)
  value = (ENV['AWS_MAX_ATTEMPTS']) ||
          Aws.shared_config.max_attempts(profile: cfg.profile)
  if value
    value = value.to_i
    # Raise if provided value is not a positive integer
    if value <= 0
      raise ArgumentError,
            'Must provide a positive integer for max_attempts profile '\
              'option or for ENV[\'AWS_MAX_ATTEMPTS\']'
    end
    return value
  end

  default_max_attempts(cfg)
end

.resolve_retry_mode(cfg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 178

def resolve_retry_mode(cfg)
  default_mode_value =
    if cfg.respond_to?(:defaults_mode_config_resolver)
      cfg.defaults_mode_config_resolver.resolve(:retry_mode)
    end

  value = ENV['AWS_RETRY_MODE'] ||
          Aws.shared_config.retry_mode(profile: cfg.profile) ||
          default_mode_value ||
          (new_retries? ? 'standard' : 'legacy') # TODO: default to 'standard' when new retries become default
  # Raise if provided value is not one of the retry modes
  if value != 'legacy' && value != 'standard' && value != 'adaptive'
    raise ArgumentError,
          'Must provide either `legacy`, `standard`, or `adaptive` for '\
            'retry_mode profile option or for ENV[\'AWS_RETRY_MODE\']'
  end
  value
end

Instance Method Details

#add_handlers(handlers, config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



522
523
524
525
526
527
528
529
530
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 522

def add_handlers(handlers, config)
  if config.retry_mode == 'legacy'
    if config.retry_limit > 0
      handlers.add(LegacyHandler, step: :sign, priority: 99)
    end
  else
    handlers.add(Handler, step: :sign, priority: 99)
  end
end