Class: DetectRepositoryLanguagesWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, ExceptionBacktrace, ExclusiveLeaseGuard
Defined in:
app/workers/detect_repository_languages_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

LEASE_TIMEOUT =
300

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_release?, #log_error, #release_lease, #renew_lease!, #try_obtain_lease

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project


13
14
15
# File 'app/workers/detect_repository_languages_worker.rb', line 13

def project
  @project
end

Instance Method Details

#perform(project_id, user_id = nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


16
17
18
19
20
21
22
23
# File 'app/workers/detect_repository_languages_worker.rb', line 16

def perform(project_id, user_id = nil)
  @project = Project.find_by(id: project_id)
  return unless project

  try_obtain_lease do
    ::Projects::DetectRepositoryLanguagesService.new(project).execute
  end
end