2017-04-05 08:19:59 -04:00
|
|
|
class GitlabUsagePingWorker
|
|
|
|
LEASE_TIMEOUT = 86400
|
|
|
|
|
|
|
|
include Sidekiq::Worker
|
2017-04-06 15:13:52 -04:00
|
|
|
include CronjobQueue
|
2017-04-05 08:19:59 -04:00
|
|
|
|
|
|
|
def perform
|
|
|
|
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
|
|
|
|
return unless try_obtain_lease
|
|
|
|
|
2017-05-24 06:25:44 -04:00
|
|
|
SubmitUsagePingService.new.execute
|
2017-04-05 08:19:59 -04:00
|
|
|
end
|
|
|
|
|
2017-05-24 06:25:44 -04:00
|
|
|
private
|
|
|
|
|
2017-04-05 08:19:59 -04:00
|
|
|
def try_obtain_lease
|
|
|
|
Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain
|
|
|
|
end
|
|
|
|
end
|