Class: Gitlab::GithubGistsImport::ImportGistWorker
- Inherits:
-
Object
- Object
- Gitlab::GithubGistsImport::ImportGistWorker
- Includes:
- ApplicationWorker
- Defined in:
- app/workers/gitlab/github_gists_import/import_gist_worker.rb
Overview
rubocop:disable Scalability/IdempotentWorker
Constant Summary collapse
- GISTS_ERRORS_BY_ID =
'gitlab:github-gists-import:%{user_id}:errors'
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
- #perform(user_id, gist_hash, notify_key) ⇒ Object
- #perform_failure(user_id, gist_hash, exception_class, exception_message, correlation_id = nil) ⇒ Object
Methods included from Loggable
Methods included from SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#perform(user_id, gist_hash, notify_key) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/workers/gitlab/github_gists_import/import_gist_worker.rb', line 32 def perform(user_id, gist_hash, notify_key) gist = representation_class.from_json_hash(gist_hash) github_identifiers = gist.github_identifiers with_logging(user_id, github_identifiers) do result = importer_class.new(gist, user_id).execute if result.success? track_gist_import('success', user_id) else error(user_id, result.errors, github_identifiers) perform_failure( user_id, gist_hash, importer_class::FileCountLimitError.name, importer_class::FILE_COUNT_LIMIT_MESSAGE ) end JobWaiter.notify(notify_key, jid, ttl: Gitlab::Import::JOB_WAITER_TTL) end rescue StandardError => e log_and_track_error(user_id, e, github_identifiers) raise end |
#perform_failure(user_id, gist_hash, exception_class, exception_message, correlation_id = nil) ⇒ Object
59 60 61 62 63 64 65 |
# File 'app/workers/gitlab/github_gists_import/import_gist_worker.rb', line 59 def perform_failure(user_id, gist_hash, exception_class, , correlation_id = nil) track_gist_import('failed', user_id) github_identifiers = representation_class.from_json_hash(gist_hash).github_identifiers persist_failure(user_id, exception_class, , github_identifiers, correlation_id) end |