lib/httpx/plugins/retries.rb in httpx-0.4.0 vs lib/httpx/plugins/retries.rb in httpx-0.4.1
- old
+ new
@@ -3,10 +3,12 @@
module HTTPX
module Plugins
#
# This plugin adds support for retrying requests when certain errors happen.
#
+ # https://gitlab.com/honeyryderchuck/httpx/wikis/Retries
+ #
module Retries
MAX_RETRIES = 3
# TODO: pass max_retries in a configure/load block
IDEMPOTENT_METHODS = %i[get options head put delete].freeze
@@ -29,11 +31,11 @@
num
end
def_option(:retry_change_requests)
- end.new(options)
+ end.new(options).merge(max_retries: MAX_RETRIES)
end
module InstanceMethods
def max_retries(n)
branch(default_options.with_max_retries(n.to_i))
@@ -69,10 +71,10 @@
module RequestMethods
attr_accessor :retries
def initialize(*args)
super
- @retries = @options.max_retries || MAX_RETRIES
+ @retries = @options.max_retries
end
end
end
register_plugin :retries, Retries
end