summaryrefslogtreecommitdiff
path: root/app/workers/concerns
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-10 18:07:43 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-10 18:07:43 +0000
commit6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be (patch)
tree8af92b29c838e9af2fd70f9a4a2314a08f4af922 /app/workers/concerns
parent8b1228b0d409d7751f01d9fb72ebfbbf62399486 (diff)
downloadgitlab-ce-6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/concerns')
-rw-r--r--app/workers/concerns/self_monitoring_project_worker.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/workers/concerns/self_monitoring_project_worker.rb b/app/workers/concerns/self_monitoring_project_worker.rb
new file mode 100644
index 00000000000..44dd6866fad
--- /dev/null
+++ b/app/workers/concerns/self_monitoring_project_worker.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module SelfMonitoringProjectWorker
+ extend ActiveSupport::Concern
+
+ included do
+ # This worker falls under Self-monitoring with Monitor::APM group. However,
+ # self-monitoring is not classified as a feature category but rather as
+ # Other Functionality. Metrics seems to be the closest feature_category for
+ # this worker.
+ feature_category :metrics
+ end
+
+ LEASE_TIMEOUT = 15.minutes.to_i
+ EXCLUSIVE_LEASE_KEY = 'self_monitoring_service_creation_deletion'
+
+ class_methods do
+ # @param job_id [String]
+ # Job ID that is used to construct the cache keys.
+ # @return [Hash]
+ # Returns true if the job is enqueued or in progress and false otherwise.
+ def in_progress?(job_id)
+ Gitlab::SidekiqStatus.job_status(Array.wrap(job_id)).first
+ end
+ end
+
+ private
+
+ def lease_key
+ EXCLUSIVE_LEASE_KEY
+ end
+
+ def lease_timeout
+ self.class::LEASE_TIMEOUT
+ end
+end