Class: Rack::Idempotent::ImmediateRetry
- Inherits:
-
Object
- Object
- Rack::Idempotent::ImmediateRetry
- Defined in:
- lib/rack-idempotent/immediate_retry.rb
Instance Attribute Summary collapse
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
Instance Method Summary collapse
- #call(request, response, exception) ⇒ Object
-
#initialize(options = {}) ⇒ ImmediateRetry
constructor
A new instance of ImmediateRetry.
Constructor Details
#initialize(options = {}) ⇒ ImmediateRetry
Returns a new instance of ImmediateRetry.
4 5 6 |
# File 'lib/rack-idempotent/immediate_retry.rb', line 4 def initialize(={}) @max_retries = [:max_retries] || Rack::Idempotent::DEFAULT_RETRY_LIMIT end |
Instance Attribute Details
#max_retries ⇒ Object (readonly)
Returns the value of attribute max_retries.
2 3 4 |
# File 'lib/rack-idempotent/immediate_retry.rb', line 2 def max_retries @max_retries end |
Instance Method Details
#call(request, response, exception) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rack-idempotent/immediate_retry.rb', line 8 def call(request, response, exception) request.env["idempotent.requests.count"] ||= 0 request.env["idempotent.requests.count"] += 1 if request.env["idempotent.requests.count"] >= max_retries raise Rack::Idempotent::RetryLimitExceeded.new( request.env["idempotent.requests.exceptions"] ) end end |