Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab_usage_ping_worker.rb « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6dd281b1147d5d6c55f4a44bc1b491ba74e95062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class GitlabUsagePingWorker
  LEASE_TIMEOUT = 86400

  include ApplicationWorker
  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