Class: CanvasSync::JobUniqueness::OnConflict::Reject

Inherits:
Base
  • Object
show all
Defined in:
lib/canvas_sync/job_uniqueness/on_conflict/reject.rb

Instance Attribute Summary

Attributes inherited from Base

#lock_context, #redis_pool

Instance Method Summary collapse

Methods inherited from Base

#initialize, #replace?, valid_for

Constructor Details

This class inherits a constructor from CanvasSync::JobUniqueness::OnConflict::Base

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/canvas_sync/job_uniqueness/on_conflict/reject.rb', line 6

def call
  # TODO Allow this to work on Sidekiq-backed ActiveJob
  unless lock_context.is_a?(CanvasSync::JobUniqueness::Compat::Sidekiq::SidekiqLockContext)
    CanvasSync::JobUniqueness.logger.error(":reject conflict strategy is not supported for non-Sidekiq-backed jobs")
    return
  end

  kwargs = {}
  kwargs[:notify_failure] = false if Sidekiq::DeadSet.instance_method(:kill).arity > 1

  sidekiq_message = lock_context.instance_variable_get(:@job_instance)
  Sidekiq::DeadSet.new.kill(JSON.dump(sidekiq_message), **kwargs)
end