62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/canvas_sync/job_batches/compat/sidekiq.rb', line 62
def call(_worker, msg, _queue)
if (bid = msg['bid'])
prev_batch = Thread.current[CURRENT_BATCH_THREAD_KEY]
begin
Thread.current[CURRENT_BATCH_THREAD_KEY] = Batch.new(bid)
yield
Thread.current[CURRENT_BATCH_THREAD_KEY].save_context_changes
Batch.process_successful_job(bid, msg['jid'])
rescue
Batch.process_failed_job(bid, msg['jid'])
raise
ensure
Thread.current[CURRENT_BATCH_THREAD_KEY] = prev_batch
end
else
yield
end
end
|