Class: GitlabUsagePingWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue, Gitlab::ExclusiveLeaseHelpers
Defined in:
app/workers/gitlab_usage_ping_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

LEASE_KEY =
'gitlab_usage_ping_worker:ping'
LEASE_TIMEOUT =
86400

Constants included from Gitlab::ExclusiveLeaseHelpers

Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::ExclusiveLeaseHelpers

#in_lock

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#performObject


15
16
17
18
19
20
21
22
23
# File 'app/workers/gitlab_usage_ping_worker.rb', line 15

def perform
  # Multiple Sidekiq workers could run this. We should only do this at most once a day.
  in_lock(LEASE_KEY, ttl: LEASE_TIMEOUT) do
    # Splay the request over a minute to avoid thundering herd problems.
    sleep(rand(0.0..60.0).round(3))

    SubmitUsagePingService.new.execute
  end
end