Class: Gitlab::ImportExport::ImportFailureService
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::ImportFailureService
- Defined in:
- lib/gitlab/import_export/import_failure_service.rb
Constant Summary collapse
- RETRIABLE_EXCEPTIONS =
[GRPC::DeadlineExceeded, ActiveRecord::QueryCanceled].freeze
Instance Attribute Summary collapse
-
#importable ⇒ Object
readonly
Returns the value of attribute importable.
Instance Method Summary collapse
-
#initialize(importable) ⇒ ImportFailureService
constructor
A new instance of ImportFailureService.
- #log_import_failure(source:, relation_key: nil, relation_index: nil, exception:, retry_count: 0) ⇒ Object
- #with_retry(action:, relation_key: nil, relation_index: nil) ⇒ Object
Constructor Details
#initialize(importable) ⇒ ImportFailureService
Returns a new instance of ImportFailureService.
10 11 12 13 |
# File 'lib/gitlab/import_export/import_failure_service.rb', line 10 def initialize(importable) @importable = importable @association = importable.association(:import_failures) end |
Instance Attribute Details
#importable ⇒ Object (readonly)
Returns the value of attribute importable.
8 9 10 |
# File 'lib/gitlab/import_export/import_failure_service.rb', line 8 def importable @importable end |
Instance Method Details
#log_import_failure(source:, relation_key: nil, relation_index: nil, exception:, retry_count: 0) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gitlab/import_export/import_failure_service.rb', line 30 def log_import_failure(source:, relation_key: nil, relation_index: nil, exception:, retry_count: 0) attributes = { relation_index: relation_index, source: source, retry_count: retry_count, importable_column_name => importable.id } Gitlab::ErrorTracking.track_exception( exception, attributes.merge(relation_name: relation_key) ) ImportFailure.create( attributes.merge( exception_class: exception.class.to_s, exception_message: exception..truncate(255), correlation_id_value: Labkit::Correlation::CorrelationId.current_or_new_id, relation_key: relation_key ) ) end |
#with_retry(action:, relation_key: nil, relation_index: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitlab/import_export/import_failure_service.rb', line 15 def with_retry(action:, relation_key: nil, relation_index: nil) on_retry = -> (exception, retry_count, *_args) do log_import_failure( source: action, relation_key: relation_key, relation_index: relation_index, exception: exception, retry_count: retry_count) end Retriable.with_context(:relation_import, on_retry: on_retry) do yield end end |