Class: CanvasSync::JobUniqueness::Compat::Sidekiq::CommonMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas_sync/job_uniqueness/compat/sidekiq.rb

Direct Known Subclasses

ClientMiddleware, ServerMiddleware

Instance Method Summary collapse

Instance Method Details

#lock_context(msg) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/canvas_sync/job_uniqueness/compat/sidekiq.rb', line 31

def lock_context(msg)
  opts = worker_uniqueness(msg)
  return nil unless opts

  SidekiqLockContext.new({
    job_clazz: msg['class'],
    jid: msg['jid'],
    queue: msg['queue'],
    args: msg['args'],
    # kwargs: msg['kwargs'],
    **(msg['uniqueness_cache_data']&.symbolize_keys || {}),
  }, job_instance: msg)
end

#worker_uniqueness(msg) ⇒ Object



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

def worker_uniqueness(msg)
  return nil if Compat::Sidekiq.is_activejob_job?(msg)

  worker_class = msg['class'].constantize
  return nil unless worker_class.respond_to?(:unique_job_options)

  worker_class.unique_job_options
end