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

20 lines
432 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
class GitlabUsagePingWorker
LEASE_TIMEOUT = 86400
include Sidekiq::Worker
include CronjobQueue
def perform
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
return unless try_obtain_lease
2017-09-10 17:25:29 +05:30
SubmitUsagePingService.new.execute
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
private
2017-08-17 22:00:37 +05:30
def try_obtain_lease
Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain
end
end