class SidekiqUniqueJobs::OnConflict::Reject
Strategy
to send jobs to dead queue
@author Mikael Henriksson <mikael@mhenrixon.com>
Public Instance Methods
Source
# File lib/sidekiq_unique_jobs/on_conflict/reject.rb, line 12 def call log_info { "Adding dead #{item[CLASS]} job #{item[JID]}" } if kill_with_options? kill_job_with_options else kill_job_without_options end end
Send jobs to dead queue
Source
# File lib/sidekiq_unique_jobs/on_conflict/reject.rb, line 69 def deadset @deadset ||= Sidekiq::DeadSet.new end
An instance of Sidekiq::Deadset @api private
@return [Sidekiq::Deadset]>
Source
# File lib/sidekiq_unique_jobs/on_conflict/reject.rb, line 59 def kill_job_with_options deadset.kill(payload, notify_failure: false) end
Executes the kill instructions with arguments @api private
@return [void]
Source
# File lib/sidekiq_unique_jobs/on_conflict/reject.rb, line 49 def kill_job_without_options deadset.kill(payload) end
Executes the kill instructions without arguments @api private
@return [void]
Source
# File lib/sidekiq_unique_jobs/on_conflict/reject.rb, line 30 def kill_with_options? kill_arity = Sidekiq::DeadSet.instance_method(:kill).arity # Method#arity returns: # 1. a nonnegative number for methods that take a fixed number of arguments. # 2. A negative number if it takes a variable number of arguments. # Keyword arguments are considered a single argument, and are considered optional unless one of the kwargs is # required. # Therefore, to determine if `Sidekiq::DeadSet#kill` accepts options beyond the single positional payload # argument, we need to check whether the absolute value of the arity is greater than 1. # See: https://apidock.com/ruby/Method/arity kill_arity > 1 || kill_arity < -1 end
Sidekiq
version compatibility check @api private
@return [true] when Sidekiq::Deadset#kill takes more than 1 argument @return [false] when Sidekiq::Deadset#kill does not take multiple arguments