Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/metrics/global_metrics_update_worker.rb')
-rw-r--r--app/workers/metrics/global_metrics_update_worker.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/workers/metrics/global_metrics_update_worker.rb b/app/workers/metrics/global_metrics_update_worker.rb
new file mode 100644
index 00000000000..326403a2f8f
--- /dev/null
+++ b/app/workers/metrics/global_metrics_update_worker.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Metrics
+ class GlobalMetricsUpdateWorker
+ include ApplicationWorker
+
+ idempotent!
+ data_consistency :sticky
+ feature_category :metrics
+
+ include ExclusiveLeaseGuard
+ # rubocop:disable Scalability/CronWorkerContext
+ # This worker does not perform work scoped to a context
+ include CronjobQueue
+ # rubocop:enable Scalability/CronWorkerContext
+
+ LEASE_TIMEOUT = 2.minutes
+
+ def perform
+ try_obtain_lease { ::Metrics::GlobalMetricsUpdateService.new.execute }
+ end
+
+ def lease_timeout
+ LEASE_TIMEOUT
+ end
+ end
+end