Class: Azure::Storage::Common::Core::Filter::ExponentialRetryPolicyFilter

Inherits:
RetryPolicyFilter
  • Object
show all
Defined in:
lib/azure/storage/common/core/filter/exponential_retry_filter.rb

Constant Summary collapse

DEFAULT_RETRY_COUNT =
3
DEFAULT_MIN_RETRY_INTERVAL =
10
DEFAULT_MAX_RETRY_INTERVAL =
90

Instance Attribute Summary collapse

Attributes inherited from RetryPolicyFilter

#retry_count, #retry_interval

Instance Method Summary collapse

Methods inherited from RetryPolicyFilter

#adjust_retry_request, #check_location, #check_status_code, #get_next_location, #init_retry_data, #should_retry?, #should_retry_on_error?, #should_retry_on_local_error?, #wait_for_retry

Constructor Details

#initialize(retry_count = nil, min_retry_interval = nil, max_retry_interval = nil) ⇒ ExponentialRetryPolicyFilter

Returns a new instance of ExponentialRetryPolicyFilter.



31
32
33
34
35
36
37
# 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

Instance Attribute Details

#max_retry_intervalObject (readonly)

Returns the value of attribute max_retry_interval.



39
40
41
# File 'lib/azure/storage/common/core/filter/exponential_retry_filter.rb', line 39

def max_retry_interval
  @max_retry_interval
end

#min_retry_intervalObject (readonly)

Returns the value of attribute min_retry_interval.



39
40
41
# File 'lib/azure/storage/common/core/filter/exponential_retry_filter.rb', line 39

def min_retry_interval
  @min_retry_interval
end

Instance Method Details

#apply_retry_policy(retry_data) ⇒ Object

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



55
56
57
58
59
60
61
62
# 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