module SidekiqUniqueJobs::OptionsWithFallback
Module containing methods shared between client and server middleware
Requires the following methods to be defined in the including class
1. item (required) 2. options (can be nil) 3. job_class (required, can be anything)
@author Mikael Henriksson <mikael@mhenrixon.com>
Public Class Methods
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 12 def self.included(base) base.send(:include, SidekiqUniqueJobs::SidekiqWorkerMethods) end
Public Instance Methods
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 48 def lock_class @lock_class ||= locks.fetch(lock_type.to_sym) do raise UnknownLock, "No implementation for `lock: :#{lock_type}`" end end
Returns the corresponding class for the lock_type
@return [Class]
Source
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 60 def lock_type @lock_type ||= options[LOCK] || item[LOCK] end
The type of lock for this worker
@return [Symbol, NilClass]
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 17 def locks SidekiqUniqueJobs.locks end
A convenience method for using the configured locks
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 70 def options @options ||= begin opts = default_job_options.dup opts.merge!(job_options) if sidekiq_job_class? (opts || {}).stringify_keys end end
The default options with any matching keys overridden from worker options
@return [Hash<String, Object>]
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 28 def unique_disabled? !unique_enabled? end
Check if unique has been disabled
Source
# File lib/sidekiq_unique_jobs/options_with_fallback.rb, line 23 def unique_enabled? SidekiqUniqueJobs.enabled? && lock_type end
Check if unique has been enabled @return [true, false] indicate if the gem has been enabled