Method: Faraday::Request::Retry#initialize

Defined in:
lib/faraday/request/retry.rb

#initialize(app, options = nil) ⇒ Retry

Public: Initialize middleware

Options: max - Maximum number of retries (default: 2) interval - Pause in seconds between retries (default: 0) interval_randomness - The maximum random interval amount expressed

as a float between 0 and 1 to use in addition to the
interval. (default: 0)

max_interval - An upper limit for the interval (default: Float::MAX) backoff_factor - The amount to multiple each successive retry’s

interval amount by in order to provide backoff
(default: 1)

exceptions - The list of exceptions to handle. Exceptions can be

given as Class, Module, or String. (default:
[Errno::ETIMEDOUT, Timeout::Error,
Error::TimeoutError])

methods - A list of HTTP methods to retry without calling retry_if. Pass

an empty Array to call retry_if for all exceptions.
(defaults to the idempotent HTTP methods in IDEMPOTENT_METHODS)

retry_if - block that will receive the env object and the exception raised

and should decide if the code should retry still the action or
not independent of the retry count. This would be useful
if the exception produced is non-recoverable or if the
the HTTP method called is not idempotent.
(defaults to return false)


97
98
99
100
101
# File 'lib/faraday/request/retry.rb', line 97

def initialize(app, options = nil)
  super(app)
  @options = Options.from(options)
  @errmatch = build_exception_matcher(@options.exceptions)
end