debian-mirror-gitlab/app/workers/propagate_service_template_worker.rb

30 lines
767 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2021-10-27 15:23:28 +05:30
# No longer in use https://gitlab.com/groups/gitlab-org/-/epics/5672
# To be removed https://gitlab.com/gitlab-org/gitlab/-/issues/335178
2020-04-08 14:13:33 +05:30
class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWorker
2018-03-17 18:26:18 +05:30
include ApplicationWorker
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
data_consistency :always
2021-06-08 01:23:25 +05:30
sidekiq_options retry: 3
2020-10-24 23:57:45 +05:30
feature_category :integrations
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
LEASE_TIMEOUT = 4.hours.to_i
def perform(template_id)
return unless try_obtain_lease_for(template_id)
2021-12-11 22:18:48 +05:30
Admin::PropagateServiceTemplate.propagate(Integration.find_by_id(template_id))
2017-08-17 22:00:37 +05:30
end
private
def try_obtain_lease_for(template_id)
2017-09-10 17:25:29 +05:30
Gitlab::ExclusiveLease
.new("propagate_service_template_worker:#{template_id}", timeout: LEASE_TIMEOUT)
.try_obtain
2017-08-17 22:00:37 +05:30
end
end