Class: Translatomatic::HTTP::Client::HttpRetryExecutor

Inherits:
RetryExecutor
  • Object
show all
Defined in:
lib/translatomatic/http/client.rb

Overview

Retry requests on server errors

Instance Method Summary collapse

Methods inherited from RetryExecutor

#initialize, #run

Constructor Details

This class inherits a constructor from Translatomatic::RetryExecutor

Instance Method Details

#http_exception?(exception) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/translatomatic/http/client.rb', line 77

def http_exception?(exception)
  exception.is_a?(Translatomatic::HTTP::Exception)
end

#retriable?(exception) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/translatomatic/http/client.rb', line 73

def retriable?(exception)
  http_exception?(exception) && retriable_exception?(exception)
end

#retriable_exception?(exception) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
84
# File 'lib/translatomatic/http/client.rb', line 81

def retriable_exception?(exception)
  RETRIABLE.any? { |i| exception.response.kind_of?(i) } ||
    RETRIABLE_CODES.include?(exception.response.code.to_i)
end