Sha256: 052706acf2d8e4004e36274d333db4e2996fbdd9afa8a9e8607a06a9a8945ef7
Contents?: true
Size: 962 Bytes
Versions: 6
Compression:
Stored size: 962 Bytes
Contents
# frozen_string_literal: true class LHC::Retry < LHC::Interceptor attr_accessor :retries, :current_retry class << self attr_accessor :max, :all end 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 private def retry?(request) return false if request.response.success? return false if !request.options.dig(:retry) && !LHC::Retry.all request.options[:retries] < max(request) end def max(request) options(request).is_a?(Hash) ? options(request).fetch(:max, LHC::Retry.max) : LHC::Retry.max end def options(request) @options ||= request.options.dig(:retry) end end LHC::Retry.max = 3
Version data entries
6 entries across 6 versions & 1 rubygems