class Azure::Storage::Common::Core::Filter::ExponentialRetryPolicyFilter

Constants

DEFAULT_MAX_RETRY_INTERVAL
DEFAULT_MIN_RETRY_INTERVAL
DEFAULT_RETRY_COUNT

Attributes

max_retry_interval[R]
min_retry_interval[R]

Public Class Methods

new(retry_count = nil, min_retry_interval = nil, max_retry_interval = nil) click to toggle source
Calls superclass method
# File lib/azure/storage/common/core/filter/exponential_retry_filter.rb, line 31
def initialize(retry_count = nil, min_retry_interval = nil, max_retry_interval = nil)
  @retry_count = retry_count || ExponentialRetryPolicyFilter::DEFAULT_RETRY_COUNT
  @min_retry_interval = min_retry_interval || ExponentialRetryPolicyFilter::DEFAULT_MIN_RETRY_INTERVAL
  @max_retry_interval = max_retry_interval || ExponentialRetryPolicyFilter::DEFAULT_MAX_RETRY_INTERVAL

  super @retry_count, @min_retry_interval
end

Public Instance Methods

apply_retry_policy(retry_data) click to toggle source

Overrides the base class implementation of call to determine how the HTTP request should continue retrying

retry_data - Hash. Stores stateful retry data

The retry_data is a Hash which can be used to store stateful data about the request execution context (such as an incrementing counter, timestamp, etc). The retry_data object will be the same instance throughout the lifetime of the request

# File lib/azure/storage/common/core/filter/exponential_retry_filter.rb, line 55
def apply_retry_policy(retry_data)
  # Adjust retry count
  retry_data[:count] = retry_data[:count] === nil ? 1 : retry_data[:count] + 1

  # Adjust retry interval
  increment_delta = (@max_retry_interval - @min_retry_interval).fdiv(2**(@retry_count - 1)) * (2**(retry_data[:count] - 1));
  retry_data[:interval] = retry_data[:interval] === nil ? @min_retry_interval : [@min_retry_interval + increment_delta, @max_retry_interval].min;
end