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

propagate_service_template_worker.rb « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 908f867279f574a70a96c601131f9c2869775ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

# No longer in use https://gitlab.com/groups/gitlab-org/-/epics/5672
# To be removed https://gitlab.com/gitlab-org/gitlab/-/issues/335178
class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWorker
  include ApplicationWorker

  data_consistency :always

  sidekiq_options retry: 3

  feature_category :integrations

  LEASE_TIMEOUT = 4.hours.to_i

  def perform(template_id)
    return unless try_obtain_lease_for(template_id)

    Admin::PropagateServiceTemplate.propagate(Integration.find_by_id(template_id))
  end

  private

  def try_obtain_lease_for(template_id)
    Gitlab::ExclusiveLease
      .new("propagate_service_template_worker:#{template_id}", timeout: LEASE_TIMEOUT)
      .try_obtain
  end
end