Exception: BulkImports::NetworkError
- Defined in:
- lib/bulk_imports/network_error.rb
Constant Summary collapse
- TRACKER_COUNTER_KEY =
'bulk_imports/%{entity_id}/%{stage}/%{tracker_id}/network_error/%{error}'
- ENTITY_COUNTER_KEY =
'bulk_imports/%{entity_id}/network_error/%{error}'
- NO_SPACE_LEFT_EXCEPTION =
Errno::ENOSPC
- DECOMPRESSION_FAILURE_EXCEPTION =
Zlib::Error
- EXCEPTIONS_RETRY_DELAY =
{ NO_SPACE_LEFT_EXCEPTION => 120, DECOMPRESSION_FAILURE_EXCEPTION => 60 }.freeze
- RETRIABLE_EXCEPTIONS =
Gitlab::HTTP::HTTP_TIMEOUT_ERRORS + EXCEPTIONS_RETRY_DELAY.keys + [ EOFError, SocketError, OpenSSL::SSL::SSLError, OpenSSL::OpenSSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH ].freeze
- RETRIABLE_HTTP_CODES =
[429, 500, 502, 503, 504].freeze
- DEFAULT_RETRY_DELAY_SECONDS =
30
- MAX_RETRIABLE_COUNT =
10
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(message = nil, response: nil) ⇒ NetworkError
constructor
A new instance of NetworkError.
- #retriable?(object) ⇒ Boolean
- #retry_delay ⇒ Object
Methods inherited from Error
destination_full_path_validation_failure, destination_namespace_validation_failure, destination_slug_validation_failure, invalid_url, not_authorized, scope_or_url_validation_failure, setting_not_enabled, source_full_path_validation_failure, unsupported_gitlab_version
Constructor Details
#initialize(message = nil, response: nil) ⇒ NetworkError
Returns a new instance of NetworkError.
29 30 31 32 33 34 35 |
# File 'lib/bulk_imports/network_error.rb', line 29 def initialize( = nil, response: nil) raise ArgumentError, 'message or response required' if .blank? && response.blank? super() @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
27 28 29 |
# File 'lib/bulk_imports/network_error.rb', line 27 def response @response end |
Instance Method Details
#retriable?(object) ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/bulk_imports/network_error.rb', line 37 def retriable?(object) if retriable_exception? || retriable_http_code? increment(object) <= MAX_RETRIABLE_COUNT else false end end |
#retry_delay ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/bulk_imports/network_error.rb', line 45 def retry_delay if response&.code == 429 response.headers.fetch('Retry-After', DEFAULT_RETRY_DELAY_SECONDS).to_i else EXCEPTIONS_RETRY_DELAY[cause&.class] || DEFAULT_RETRY_DELAY_SECONDS end.seconds end |