diff options
Diffstat (limited to 'app/workers/gitlab_usage_ping_worker.rb')
-rw-r--r-- | app/workers/gitlab_usage_ping_worker.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb new file mode 100644 index 00000000000..0a55aab63fd --- /dev/null +++ b/app/workers/gitlab_usage_ping_worker.rb @@ -0,0 +1,19 @@ +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 |