Sha256: d61dbee67430aaca3dcaeb128b34606a1582edbe3f3f6ce4b64b5f37bbd5c42e
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Excon module Middleware class Idempotent < Excon::Middleware::Base def error_call(datum) if datum[:idempotent] if datum.has_key?(:request_block) if datum[:request_block].respond_to?(:rewind) datum[:request_block].rewind else Excon.display_warning('Excon requests with a :request_block must implement #rewind in order to be :idempotent.') datum[:idempotent] = false end end if datum.has_key?(:pipeline) Excon.display_warning("Excon requests can not be :idempotent when pipelining.") datum[:idempotent] = false end end if datum[:idempotent] && [Excon::Errors::Timeout, Excon::Errors::SocketError, Excon::Errors::HTTPStatusError].any? {|ex| datum[:error].kind_of?(ex) } && datum[:retries_remaining] > 1 sleep(datum[:retry_interval]) if datum[:retry_interval] # reduces remaining retries, reset connection, and restart request_call datum[:retries_remaining] -= 1 connection = datum.delete(:connection) datum.reject! {|key, _| !Excon::VALID_REQUEST_KEYS.include?(key) } connection.request(datum) else @stack.error_call(datum) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
excon-0.59.0 | lib/excon/middlewares/idempotent.rb |
excon-0.58.0 | lib/excon/middlewares/idempotent.rb |