module SidekiqUniqueJobs
Module with constants to avoid string duplication
@author Mikael Henriksson <mikael@mhenrixon.com>
Contains configuration and utility methods that belongs top level
@author Mikael Henriksson <mikael@mhenrixon.com>
Constants
- APARTMENT
- ARGS
- AT
- CHANGELOGS
- CLASS
- CREATED_AT
- DEAD_VERSION
- DIGESTS
- ERRORS
- JID
- LIMIT
- LIVE_VERSION
- LOCK
- LOCK_ARGS
- LOCK_ARGS_METHOD
- LOCK_DIGEST
- LOCK_EXPIRATION
- LOCK_INFO
- LOCK_LIMIT
- LOCK_PREFIX
- LOCK_TIMEOUT
- LOCK_TTL
- LOCK_TYPE
- ON_CLIENT_CONFLICT
- ON_CONFLICT
- ON_SERVER_CONFLICT
- PAYLOAD
- PROCESSES
- QUEUE
- RETRY
- SCHEDULE
- TIME
- TIMEOUT
- TTL
- TYPE
- ThreadSafeConfig
ThreadSafe config exists to be able to document the config class without errors
- UNIQUE
- UNIQUE_ACROSS_QUEUES
- UNIQUE_ACROSS_WORKERS
- UNIQUE_ARGS
- UNIQUE_ARGS_METHOD
- UNIQUE_DIGEST
- UNIQUE_PREFIX
- UNIQUE_REAPER
- VERSION
@return [String] the current
SidekiqUniqueJobs
version- WORKER
Public Instance Methods
The current configuration (See: {.configure} on how to configure)
@return [SidekiqUniqueJobs::Config] the gem configuration
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 19 def config @config ||= reset! end
Disable SidekiqUniuqeJobs either temporarily in a block or for good
@return [false] when not given a block @return [true, false] the previous value of enable when given a block
@yieldreturn [void] temporarily disable sidekiq unique jobs while executing a block of code
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 124 def disable!(&block) toggle(false, &block) end
Checks if the gem has been disabled
@return [true] when config.enabled is false @return [false] when config.enabled is true
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 144 def disabled? !enabled? end
Enable SidekiqUniuqeJobs either temporarily in a block or for good
@return [true] when not given a block @return [true, false] the previous value of enable when given a block
@yieldreturn [void] temporarily enable sidekiq unique jobs while executing a block of code
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 112 def enable!(&block) toggle(true, &block) end
Checks if the gem has been disabled
@return [true] when config.enabled is true @return [false] when config.enabled is false
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 134 def enabled? config.enabled end
The current locks
@return [Hash<Symbol, SidekiqUniqueJobs::BaseLock>] the configured locks
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 39 def locks config.locks end
The current logger
@return [Logger] the configured logger
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 49 def logger config.logger end
Set a new logger
@param [Logger] other another logger
@return [Logger] the new logger
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 70 def logger=(other) config.logger = other end
Resets configuration to deafult
@return [SidekiqUniqueJobs::Config] a default gem configuration
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 100 def reset! @config = SidekiqUniqueJobs::Config.default end
The current strategies
@return [Hash<Symbol, SidekiqUniqueJobs::Strategy>] the configured locks
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 29 def strategies config.strategies end
Temporarily use another configuration and reset to the old config after yielding
@param [Hash] tmp_config the temporary configuration to use
@return [void]
@yield control to the caller
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 82 def use_config(tmp_config = {}) raise ::ArgumentError, "#{name}.#{__method__} needs a block" unless block_given? old_config = config.to_h reset! configure(tmp_config) yield ensure reset! configure(old_config.to_h) end
The current gem version
@return [String] the current gem version
# File lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb, line 59 def version VERSION end