Class: LHC::Retry
- Inherits:
-
Interceptor
- Object
- Interceptor
- LHC::Retry
- Defined in:
- lib/lhc/interceptors/retry.rb
Class Attribute Summary collapse
-
.all ⇒ Object
Returns the value of attribute all.
-
.max ⇒ Object
Returns the value of attribute max.
Instance Attribute Summary collapse
-
#current_retry ⇒ Object
Returns the value of attribute current_retry.
-
#retries ⇒ Object
Returns the value of attribute retries.
Attributes inherited from Interceptor
Instance Method Summary collapse
Methods inherited from Interceptor
#after_request, #all_interceptor_classes, #before_raw_request, #before_request, #before_response, dup, #initialize, #response
Constructor Details
This class inherits a constructor from LHC::Interceptor
Class Attribute Details
.all ⇒ Object
Returns the value of attribute all.
7 8 9 |
# File 'lib/lhc/interceptors/retry.rb', line 7 def all @all end |
.max ⇒ Object
Returns the value of attribute max.
7 8 9 |
# File 'lib/lhc/interceptors/retry.rb', line 7 def max @max end |
Instance Attribute Details
#current_retry ⇒ Object
Returns the value of attribute current_retry.
4 5 6 |
# File 'lib/lhc/interceptors/retry.rb', line 4 def current_retry @current_retry end |
#retries ⇒ Object
Returns the value of attribute retries.
4 5 6 |
# File 'lib/lhc/interceptors/retry.rb', line 4 def retries @retries end |
Instance Method Details
#after_response ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lhc/interceptors/retry.rb', line 10 def after_response response.request.[:retries] ||= 0 return unless retry?(response.request) response.request.[:retries] += 1 current_retry = response.request.[:retries] begin response.request.run! rescue LHC::Error return end response.request.response if current_retry == response.request.[:retries] end |