Sha256: 3d817168cd7aee141524f17a142b043871677215d36647fd2116025939be5be0
Contents?: true
Size: 608 Bytes
Versions: 2
Compression:
Stored size: 608 Bytes
Contents
# Adds support to retrying a request if the result is 503. # # To use it, load it in your dsl: # Restfulie.at("http://localhost:3000/product/2").retry_when_unavailable.get module Restfulie::Client::Feature class RetryWhenUnavailable def execute(chain, request, env) resp = chain.continue(request, env) if should_retry?(resp, env) resp = chain.continue(request, env) end resp end protected # extension point that allows you to redefine # when a request should be retried def should_retry?(response, env) response.code.to_i == 503 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restfulie-1.0.0.beta5 | lib/restfulie/client/feature/retry_when_unavailable.rb |
restfulie-1.0.0.beta4 | lib/restfulie/client/feature/retry_when_unavailable.rb |