diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-13 06:08:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-13 06:08:51 +0300 |
commit | b9abe8515111c39c65321258d760aaf4773cb55f (patch) | |
tree | a58816df2053183f855389c37945ed17578a76aa /app/workers | |
parent | fa1b90364dc73f27dc78b9d27114e4a197f2cfcb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 9 | ||||
-rw-r--r-- | app/workers/metrics/global_metrics_update_worker.rb | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 89f8867fe62..6c3b4990023 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -543,6 +543,15 @@ :weight: 1 :idempotent: true :tags: [] +- :name: cronjob:metrics_global_metrics_update + :worker_name: Metrics::GlobalMetricsUpdateWorker + :feature_category: :metrics + :has_external_dependencies: false + :urgency: :low + :resource_boundary: :unknown + :weight: 1 + :idempotent: true + :tags: [] - :name: cronjob:namespaces_in_product_marketing_emails :worker_name: Namespaces::InProductMarketingEmailsWorker :feature_category: :experimentation_activation 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 |