7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/idempotent/rack.rb', line 7
def call(env)
request = ::Rack::Request.new(env)
response = nil
exception = nil
while true
retry_policy.call(request, response, exception) if response || exception
response, exception = nil
begin
status, , body = @app.call(env.dup)
response = ::Rack::Response.new(body, status, )
next if rescue_policy.call(request, response, exception)
return [status, , body]
rescue Idempotent::Retryable => exception
store_exception(exception, request)
next
rescue => exception
if rescue_policy.call(request, response, exception)
store_exception(exception, request)
next
end
raise
end
end
end
|