2019-08-20 15:25:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module SidekiqMiddleware
|
|
|
|
class Monitor
|
|
|
|
def call(worker, job, queue)
|
2019-09-10 12:12:05 +00:00
|
|
|
Gitlab::SidekiqDaemon::Monitor.instance.within_job(job['jid'], queue) do
|
2019-08-20 15:25:04 +00:00
|
|
|
yield
|
|
|
|
end
|
2019-09-10 12:12:05 +00:00
|
|
|
rescue Gitlab::SidekiqDaemon::Monitor::CancelledError
|
2019-08-21 19:15:03 +00:00
|
|
|
# push job to DeadSet
|
|
|
|
payload = ::Sidekiq.dump_json(job)
|
|
|
|
::Sidekiq::DeadSet.new.kill(payload, notify_failure: false)
|
|
|
|
|
2019-08-21 10:03:42 +00:00
|
|
|
# ignore retries
|
2019-08-21 19:15:03 +00:00
|
|
|
raise ::Sidekiq::JobRetry::Skip
|
2019-08-20 15:25:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|