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

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

.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.



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

def self.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.



213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 213

def self.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.



185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 185

def self.resolve_max_attempts(cfg)
  value = (ENV['AWS_MAX_ATTEMPTS']) ||
          Aws.shared_config.max_attempts(profile: cfg.profile) ||
          '3'
  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
  value
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.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 166

def self.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 ||
            'legacy'
  # 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.



430
431
432
433
434
435
436
437
438
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 430

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