BigW Consortium Gitlab

gitlab_usage_ping_worker.rb 432 Bytes
Newer Older
1 2 3 4
class GitlabUsagePingWorker
  LEASE_TIMEOUT = 86400

  include Sidekiq::Worker
5
  include CronjobQueue
6 7 8 9 10

  def perform
    # Multiple Sidekiq workers could run this. We should only do this at most once a day.
    return unless try_obtain_lease

11
    SubmitUsagePingService.new.execute
12 13
  end

14 15
  private

16 17 18 19
  def try_obtain_lease
    Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain
  end
end