Class: CanvasSync::JobBatches::Compat::Sidekiq::ClientMiddleware

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::ClientMiddleware
Defined in:
lib/canvas_sync/job_batches/compat/sidekiq.rb

Instance Method Summary collapse

Instance Method Details

#call(_worker, msg, _queue, _redis_pool = nil) ⇒ Object



46
47
48
49
50
51
# File 'lib/canvas_sync/job_batches/compat/sidekiq.rb', line 46

def call(_worker, msg, _queue, _redis_pool = nil)
  if (batch = Thread.current[CURRENT_BATCH_THREAD_KEY]) && should_handle_batch?(msg)
    batch.append_jobs(msg['jid']) if (msg['bid'] = batch.bid)
  end
  yield
end

#should_handle_batch?(msg) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
# File 'lib/canvas_sync/job_batches/compat/sidekiq.rb', line 53

def should_handle_batch?(msg)
  return false if CanvasSync::JobBatches::Compat::Sidekiq.is_activejob_job?(msg)
  true
end