class LinodeAPI::Retryable
A wrapper for the Raw
API that can retry retryable errors
Public Class Methods
new(params = {})
click to toggle source
Calls superclass method
LinodeAPI::Raw::new
# File lib/linodeapi/retryable.rb, line 5 def initialize(params = {}) super @options[:max_retries] ||= 3 @options[:max_delay] ||= 60 end
Private Instance Methods
call(*args)
click to toggle source
# File lib/linodeapi/retryable.rb, line 15 def call(*args) call_with_retries(max_retries, *args) end
Also aliased as: single_call
call_with_retries(remaining, *args)
click to toggle source
# File lib/linodeapi/retryable.rb, line 19 def call_with_retries(remaining, *args) single_call(*args) rescue RetryableHTTPError => e raise(RetriedHTTPError.new(e.code, max_retries)) if remaining < 0 delay = [e.delay, max_delay].min sleep delay call_with_retries(remaining - 1, *args) end
max_delay()
click to toggle source
# File lib/linodeapi/retryable.rb, line 32 def max_delay @options[:max_delay] end
max_retries()
click to toggle source
# File lib/linodeapi/retryable.rb, line 28 def max_retries @options[:max_retries] end