5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/sidekiq_job_controller/server_middleware.rb', line 5
def call(job, payload, _queue)
class_name = payload["wrapped"] || payload["class"]
controller_result = SidekiqJobController::Controller.new(
class_name: class_name, job: job, payload: payload
).fetch_execution_action
if controller_result.blank?
yield
elsif controller_result["action"] == "skip"
log("FORCED SKIP ACTIVATED: Skipped performing job #{class_name} - #{job.jid}")
elsif controller_result["action"] == "requeue"
log("FORCED REQUEUE ACTIVATED: Requeuing job in #{controller_result["in"].to_i} seconds - #{class_name} - #{job.jid}")
Sidekiq::Client.push(payload.merge("at" => Time.now.to_i + controller_result["in"].to_i))
else
log("UNEXPECTED ACTION: #{controller_result["action"]} is not recognized in #{class_name} - #{job.jid}")
yield
end
end
|