Module: HTTPX::Plugins::Retries::OptionsMethods
- Defined in:
- lib/httpx/plugins/retries.rb
Overview
adds support for the following options:
:max_retries :: max number of times a request will be retried (defaults to 3). :retry_change_requests :: whether idempotent requests are retried (defaults to false). :retry_after:: seconds after which a request is retried; can also be a callable object (i.e. ->(req, res) { ... } ) :retry_jitter :: number of seconds applied to :retry_after (must be a callable, i.e. ->(retry_after) { ... } ). :retry_on :: callable which alternatively defines a different rule for when a response is to be retried (i.e. ->(res) { ... }).
Instance Method Summary collapse
- #option_max_retries(value) ⇒ Object
- #option_retry_after(value) ⇒ Object
- #option_retry_change_requests(v) ⇒ Object
- #option_retry_jitter(value) ⇒ Object
- #option_retry_on(value) ⇒ Object
Instance Method Details
#option_max_retries(value) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/httpx/plugins/retries.rb', line 72 def option_max_retries(value) num = Integer(value) raise TypeError, ":max_retries must be positive" unless num >= 0 num end |
#option_retry_after(value) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/httpx/plugins/retries.rb', line 55 def option_retry_after(value) # return early if callable unless value.respond_to?(:call) value = Float(value) raise TypeError, ":retry_after must be positive" unless value.positive? end value end |
#option_retry_change_requests(v) ⇒ Object
79 80 81 |
# File 'lib/httpx/plugins/retries.rb', line 79 def option_retry_change_requests(v) v end |
#option_retry_jitter(value) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/httpx/plugins/retries.rb', line 65 def option_retry_jitter(value) # return early if callable raise TypeError, ":retry_jitter must be callable" unless value.respond_to?(:call) value end |
#option_retry_on(value) ⇒ Object
83 84 85 86 87 |
# File 'lib/httpx/plugins/retries.rb', line 83 def option_retry_on(value) raise TypeError, ":retry_on must be called with the response" unless value.respond_to?(:call) value end |