class LHC::Retry
def after_response
def after_response response.request.options[:retries] ||= 0 return unless retry?(response.request) response.request.options[:retries] += 1 current_retry = response.request.options[:retries] begin response.request.run! rescue LHC::Error return end response.request.response if current_retry == response.request.options[:retries] end
def max(request)
def max(request) options(request).is_a?(Hash) ? options(request).fetch(:max, LHC::Retry.max) : LHC::Retry.max end
def options(request)
def options(request) @options ||= request.options.dig(:retry) end
def retry?(request)
def retry?(request) return false if request.response.success? return false if request.error_ignored? return false if !request.options.dig(:retry) && !LHC::Retry.all request.options[:retries] < max(request) end