gitlab-org--gitlab-foss/app/workers/gitlab_usage_ping_worker.rb

22 lines
465 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class GitlabUsagePingWorker
LEASE_TIMEOUT = 86400
include ApplicationWorker
2017-04-06 15:13:52 -04:00
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
SubmitUsagePingService.new.execute
end
private
def try_obtain_lease
Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain
end
end