Class: Gitlab::GithubImport::RefreshImportJidWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, Queue
Defined in:
app/workers/gitlab/github_import/refresh_import_jid_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

INTERVAL =

The interval to schedule new instances of this job at.

1.minute.to_i

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Class Method Details

.perform_in_the_future(*args) ⇒ Object


16
17
18
# File 'app/workers/gitlab/github_import/refresh_import_jid_worker.rb', line 16

def self.perform_in_the_future(*args)
  perform_in(INTERVAL, *args)
end

Instance Method Details

#find_import_state(project_id) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


39
40
41
42
43
# File 'app/workers/gitlab/github_import/refresh_import_jid_worker.rb', line 39

def find_import_state(project_id)
  ProjectImportState.select(:jid)
    .with_status(:started)
    .find_by(project_id: project_id)
end

#perform(project_id, check_job_id) ⇒ Object

project_id - The ID of the project that is being imported. check_job_id - The ID of the job for which to check the status.


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/gitlab/github_import/refresh_import_jid_worker.rb', line 22

def perform(project_id, check_job_id)
  import_state = find_import_state(project_id)
  return unless import_state

  if SidekiqStatus.running?(check_job_id)
    # As long as the repository is being cloned we want to keep refreshing
    # the import JID status.
    import_state.refresh_jid_expiration
    self.class.perform_in_the_future(project_id, check_job_id)
  end

  # If the job is no longer running there's nothing else we need to do. If
  # the clone job completed successfully it will have scheduled the next
  # stage, if it died there's nothing we can do anyway.
end