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.


192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 192

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.


206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 206

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.


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

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.


165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 165

def self.resolve_retry_mode(cfg)
  value = ENV['AWS_RETRY_MODE'] ||
          Aws.shared_config.retry_mode(profile: cfg.profile) ||
          '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.


405
406
407
408
409
410
411
412
413
# File 'lib/aws-sdk-core/plugins/retry_errors.rb', line 405

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