summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-11-29 16:30:17 +0100
committerDouwe Maan <douwe@selenight.nl>2017-12-05 11:59:39 +0100
commit1e6ca3c41ead23c5e433460c8c807ea73d9ec0ef (patch)
treeed6a5da0def848adc1a15f80e69d9c55651895a4 /app/workers
parenta5c3f1c8ff7da20183b172b2b0693a6010c9e86d (diff)
downloadgitlab-ce-1e6ca3c41ead23c5e433460c8c807ea73d9ec0ef.tar.gz
Consistently schedule Sidekiq jobsdm-application-worker
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/authorized_projects_worker.rb5
-rw-r--r--app/workers/background_migration_worker.rb28
-rw-r--r--app/workers/concerns/application_worker.rb15
-rw-r--r--app/workers/expire_build_artifacts_worker.rb2
-rw-r--r--app/workers/namespaceless_project_destroy_worker.rb4
5 files changed, 16 insertions, 38 deletions
diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb
index d4f334ec3b8..09559e3b696 100644
--- a/app/workers/authorized_projects_worker.rb
+++ b/app/workers/authorized_projects_worker.rb
@@ -16,11 +16,6 @@ class AuthorizedProjectsWorker
waiter.wait
end
- # Schedules multiple jobs to run in sidekiq without waiting for completion
- def self.bulk_perform_async(args_list)
- Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list)
- end
-
# Performs multiple jobs directly. Failed jobs will be put into sidekiq so
# they can benefit from retries
def self.bulk_perform_inline(args_list)
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb
index 65791c4eaba..aeb3bc019b9 100644
--- a/app/workers/background_migration_worker.rb
+++ b/app/workers/background_migration_worker.rb
@@ -1,34 +1,6 @@
class BackgroundMigrationWorker
include ApplicationWorker
- # Enqueues a number of jobs in bulk.
- #
- # The `jobs` argument should be an Array of Arrays, each sub-array must be in
- # the form:
- #
- # [migration-class, [arg1, arg2, ...]]
- def self.perform_bulk(jobs)
- Sidekiq::Client.push_bulk('class' => self,
- 'queue' => sidekiq_options['queue'],
- 'args' => jobs)
- end
-
- # Schedules multiple jobs in bulk, with a delay.
- #
- def self.perform_bulk_in(delay, jobs)
- now = Time.now.to_i
- schedule = now + delay.to_i
-
- if schedule <= now
- raise ArgumentError, 'The schedule time must be in the future!'
- end
-
- Sidekiq::Client.push_bulk('class' => self,
- 'queue' => sidekiq_options['queue'],
- 'args' => jobs,
- 'at' => schedule)
- end
-
# Performs the background migration.
#
# See Gitlab::BackgroundMigration.perform for more information.
diff --git a/app/workers/concerns/application_worker.rb b/app/workers/concerns/application_worker.rb
index bf1ecaa0c6d..9c3bdabc49e 100644
--- a/app/workers/concerns/application_worker.rb
+++ b/app/workers/concerns/application_worker.rb
@@ -21,5 +21,20 @@ module ApplicationWorker
def queue
get_sidekiq_options['queue'].to_s
end
+
+ def bulk_perform_async(args_list)
+ Sidekiq::Client.push_bulk('class' => self, 'args' => args_list)
+ end
+
+ def bulk_perform_in(delay, args_list)
+ now = Time.now.to_i
+ schedule = now + delay.to_i
+
+ if schedule <= now
+ raise ArgumentError, 'The schedule time must be in the future!'
+ end
+
+ Sidekiq::Client.push_bulk('class' => self, 'args' => args_list, 'at' => schedule)
+ end
end
end
diff --git a/app/workers/expire_build_artifacts_worker.rb b/app/workers/expire_build_artifacts_worker.rb
index 73ab4211080..87e5dca01fd 100644
--- a/app/workers/expire_build_artifacts_worker.rb
+++ b/app/workers/expire_build_artifacts_worker.rb
@@ -8,6 +8,6 @@ class ExpireBuildArtifactsWorker
build_ids = Ci::Build.with_expired_artifacts.pluck(:id)
build_ids = build_ids.map { |build_id| [build_id] }
- Sidekiq::Client.push_bulk('class' => ExpireBuildInstanceArtifactsWorker, 'args' => build_ids )
+ ExpireBuildInstanceArtifactsWorker.bulk_perform_async(build_ids)
end
end
diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb
index 13d750e5876..adb25c2a170 100644
--- a/app/workers/namespaceless_project_destroy_worker.rb
+++ b/app/workers/namespaceless_project_destroy_worker.rb
@@ -8,10 +8,6 @@ class NamespacelessProjectDestroyWorker
include ApplicationWorker
include ExceptionBacktrace
- def self.bulk_perform_async(args_list)
- Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list)
- end
-
def perform(project_id)
begin
project = Project.unscoped.find(project_id)