Module: OCI::Retry::Functions::ShouldRetryOnError

Defined in:
lib/oci/retry/functions/should_retry_on_error.rb

Overview

A module containing functions that can be used to determine whether to retry based on the error/exception encountered.

These functions should take a single argument of a Internal::RetryState object

Class Method Summary collapse

Class Method Details

.retry_on_network_error_throttle_and_internal_server_errorsProc

Returns a proc which will retry on Errors::NetworkError and on Errors::ServiceError when the status code indicates a throttle (HTTP 429) or an internal server error (any HTTP 5xx)

Returns:

  • (Proc)


17
18
19
20
21
22
23
24
# File 'lib/oci/retry/functions/should_retry_on_error.rb', line 17

def self.retry_on_network_error_throttle_and_internal_server_errors
  lambda do |retry_state|
    return true if retry_state.last_exception.is_a?(OCI::Errors::NetworkError)
    return false unless retry_state.last_exception.is_a?(OCI::Errors::ServiceError)

    retry_state.last_exception.status_code == 429 || retry_state.last_exception.status_code >= 500
  end
end