debian-mirror-gitlab/lib/gitlab/sidekiq_middleware/monitor.rb

23 lines
572 B
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2022-03-02 08:16:31 +05:30
require 'sidekiq/job_retry'
2019-12-04 20:38:33 +05:30
module Gitlab
module SidekiqMiddleware
class Monitor
def call(worker, job, queue)
2019-12-21 20:55:43 +05:30
Gitlab::SidekiqDaemon::Monitor.instance.within_job(worker.class, job['jid'], queue) do
2019-12-04 20:38:33 +05:30
yield
end
rescue Gitlab::SidekiqDaemon::Monitor::CancelledError
# push job to DeadSet
payload = ::Sidekiq.dump_json(job)
::Sidekiq::DeadSet.new.kill(payload, notify_failure: false)
# ignore retries
raise ::Sidekiq::JobRetry::Skip
end
end
end
end