gitlab-org--gitlab-foss/app/workers/gitlab_usage_ping_worker.rb
Taurie Davis, Simon Knox and Adam Niedzielski 26dde5f55f Add Conversational Development Index page to admin panel
2017-06-01 17:37:21 +02:00

19 lines
432 B
Ruby

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
SubmitUsagePingService.new.execute
end
private
def try_obtain_lease
Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain
end
end