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
Defined Under Namespace
Classes: ErrorCodeTuple
Constant Summary collapse
- DEFAULT_RETRY_MAPPING =
{ ErrorCodeTuple.new(409, 'IncorrectState') => true, ErrorCodeTuple.new(429, 'TooManyRequests') => true, ErrorCodeTuple.new(501, 'MethodNotImplemented') => false }.freeze
Class Method Summary collapse
-
.default_retry_strategy_proc ⇒ Proc
rubocop:disable Metrics/AbcSize Returns a proc which will retry on Errors::NetworkError and on Errors::ServiceError when the status code is (409, IncorrectState) and (429, TooManyRequests) or an internal server error (any HTTP 5xx except 501 MethodNotImplemented).
-
.retry_on_network_error_throttle_and_internal_server_errors ⇒ Proc
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).
-
.retry_strategy_with_customized_retry_mapping_proc(retry_mapping) ⇒ Proc
rubocop:disable Metrics/AbcSize Returns a proc which will retry on Errors::NetworkError and on Errors::ServiceError And accept customized retry map for additional retry support.
Class Method Details
.default_retry_strategy_proc ⇒ Proc
rubocop:disable Metrics/AbcSize Returns a proc which will retry on Errors::NetworkError and on Errors::ServiceError when the status code is (409, IncorrectState) and (429, TooManyRequests) or an internal server error (any HTTP 5xx except 501 MethodNotImplemented)
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/oci/retry/functions/should_retry_on_error.rb', line 44 def self.default_retry_strategy_proc 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) if DEFAULT_RETRY_MAPPING.key?(ErrorCodeTuple.new(retry_state.last_exception.status_code, retry_state.last_exception.service_code)) return DEFAULT_RETRY_MAPPING[ErrorCodeTuple.new(retry_state.last_exception.status_code, retry_state.last_exception.service_code)] end retry_state.last_exception.status_code >= 500 end # rubocop:enable Metrics/AbcSize end |
.retry_on_network_error_throttle_and_internal_server_errors ⇒ Proc
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)
29 30 31 32 33 34 35 36 |
# File 'lib/oci/retry/functions/should_retry_on_error.rb', line 29 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 |
.retry_strategy_with_customized_retry_mapping_proc(retry_mapping) ⇒ Proc
rubocop:disable Metrics/AbcSize Returns a proc which will retry on Errors::NetworkError and on Errors::ServiceError And accept customized retry map for additional retry support
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/oci/retry/functions/should_retry_on_error.rb', line 65 def self.retry_strategy_with_customized_retry_mapping_proc(retry_mapping) lambda do |retry_state| return true if retry_state.last_exception.is_a?(Circuitbox::ServiceFailureError) return true if retry_state.last_exception.is_a?(Circuitbox::OpenCircuitError) return true if retry_state.last_exception.is_a?(OCI::Errors::NetworkError) return false unless retry_state.last_exception.is_a?(OCI::Errors::ServiceError) if retry_mapping.key?(ErrorCodeTuple.new(retry_state.last_exception.status_code, retry_state.last_exception.service_code)) return retry_mapping[ErrorCodeTuple.new(retry_state.last_exception.status_code, retry_state.last_exception.service_code)] end retry_state.last_exception.status_code >= 500 end # rubocop:enable Metrics/AbcSize end |