Class: SidekiqUniqueJobs::Config
- Inherits:
-
ThreadSafeConfig
- Object
- SidekiqUniqueJobs::Config
- Defined in:
- lib/sidekiq_unique_jobs/config.rb
Overview
Shared class for dealing with gem configuration
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- LOCKS_WHILE_ENQUEUED =
Returns Hash<Symbol, SidekiqUniqueJobs::Lock::BaseLock] all available queued locks.
{ until_executing: SidekiqUniqueJobs::Lock::UntilExecuting, while_enqueued: SidekiqUniqueJobs::Lock::UntilExecuting, }.freeze
- LOCKS_FROM_PUSH_TO_PROCESSED =
Returns Hash<Symbol, SidekiqUniqueJobs::Lock::BaseLock] all available fulltime locks.
{ until_completed: SidekiqUniqueJobs::Lock::UntilExecuted, until_executed: SidekiqUniqueJobs::Lock::UntilExecuted, until_performed: SidekiqUniqueJobs::Lock::UntilExecuted, until_processed: SidekiqUniqueJobs::Lock::UntilExecuted, until_and_while_executing: SidekiqUniqueJobs::Lock::UntilAndWhileExecuting, until_successfully_completed: SidekiqUniqueJobs::Lock::UntilExecuted, }.freeze
- LOCKS_WITHOUT_UNLOCK =
Returns Hash<Symbol, SidekiqUniqueJobs::Lock::BaseLock] all available locks without unlock.
{ until_expired: SidekiqUniqueJobs::Lock::UntilExpired, }.freeze
- LOCKS_WHEN_BUSY =
Returns Hash<Symbol, SidekiqUniqueJobs::Lock::BaseLock] all available runtime/client locks.
{ around_perform: SidekiqUniqueJobs::Lock::WhileExecuting, while_busy: SidekiqUniqueJobs::Lock::WhileExecuting, while_executing: SidekiqUniqueJobs::Lock::WhileExecuting, while_working: SidekiqUniqueJobs::Lock::WhileExecuting, while_executing_reject: SidekiqUniqueJobs::Lock::WhileExecutingReject, }.freeze
- LOCKS =
Returns Hash<Symbol, SidekiqUniqueJobs::Lock::BaseLock] all available default locks.
LOCKS_WHEN_BUSY.dup .merge(LOCKS_WHILE_ENQUEUED.dup) .merge(LOCKS_WITHOUT_UNLOCK.dup) .merge(LOCKS_FROM_PUSH_TO_PROCESSED.dup) .freeze
- STRATEGIES =
Returns Hash<Symbol, SidekiqUniqueJobs::OnConflict::Strategy] all available default strategies.
{ log: SidekiqUniqueJobs::OnConflict::Log, raise: SidekiqUniqueJobs::OnConflict::Raise, reject: SidekiqUniqueJobs::OnConflict::Reject, replace: SidekiqUniqueJobs::OnConflict::Replace, reschedule: SidekiqUniqueJobs::OnConflict::Reschedule, }.freeze
- PREFIX =
Returns by default we use this prefix.
"uniquejobs"
- LOCK_TIMEOUT =
Returns by default don’t wait for locks.
0
- LOCK_TTL =
nil
- LOGGER_ENABLED =
Returns by default false (don’t disable logger).
true
- ENABLED =
Returns by default the gem is enabled.
true
- DEBUG_LUA =
Returns by default we don’t debug the lua scripts because it is slow.
false
- MAX_HISTORY =
Returns use a changelog history of 1_000 entries by default.
1_000
- REAPER =
Returns prefer the ruby reaper by default since the lua reaper still has problems.
:ruby
- REAPER_COUNT =
Returns reap 1_000 orphaned locks at a time by default.
1_000
- REAPER_INTERVAL =
Returns reap locks every 10 minutes.
600
- REAPER_TIMEOUT =
Returns stop reaper after 10 seconds.
10
- REAPER_RESURRECTOR_INTERVAL =
Returns check if reaper is dead each 3600 seconds.
3600
- REAPER_RESURRECTOR_ENABLED =
Returns enable reaper resurrector.
false
- USE_LOCK_INFO =
Returns while useful it also adds overhead so disable lock_info by default.
false
- RAISE_ON_CONFIG_ERROR =
Returns by default we don’t raise validation errors for workers.
false
- REDIS_VERSION =
Returns default redis version is only to avoid NoMethodError on nil.
"0.0.0"
Class Method Summary collapse
-
.default ⇒ SidekiqUniqueJobs::Config
Returns a default configuration.
Instance Method Summary collapse
-
#add_lock(name, klass) ⇒ void
Adds a lock type to the configuration.
-
#add_strategy(name, klass) ⇒ Object
Adds an on_conflict strategy to the configuration.
-
#class_name ⇒ String
Memoized variable to get the class name.
- #default_lock_timeout ⇒ nil, Integer deprecated Deprecated.
- #default_lock_timeout=(obj) ⇒ Integer deprecated Deprecated.
- #default_lock_ttl ⇒ nil, Integer deprecated Deprecated.
- #default_lock_ttl=(obj) ⇒ <type> deprecated Deprecated.
-
#redis_version ⇒ String
The current version of redis.
Class Method Details
.default ⇒ SidekiqUniqueJobs::Config
Returns a default configuration
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 180 def self.default # rubocop:disable Metrics/MethodLength new( LOCK_TIMEOUT, LOCK_TTL, ENABLED, PREFIX, Sidekiq.logger, LOGGER_ENABLED, LOCKS, STRATEGIES, DEBUG_LUA, MAX_HISTORY, REAPER, REAPER_COUNT, REAPER_INTERVAL, REAPER_TIMEOUT, REAPER_RESURRECTOR_INTERVAL, REAPER_RESURRECTOR_ENABLED, USE_LOCK_INFO, RAISE_ON_CONFIG_ERROR, REDIS_VERSION, ) end |
Instance Method Details
#add_lock(name, klass) ⇒ void
This method returns an undefined value.
Adds a lock type to the configuration. It will raise if the lock exists already
280 281 282 283 284 285 286 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 280 def add_lock(name, klass) lock_sym = name.to_sym raise DuplicateLock, ":#{name} already defined, please use another name" if locks.key?(lock_sym) new_locks = locks.dup.merge(lock_sym => klass).freeze self.locks = new_locks end |
#add_strategy(name, klass) ⇒ Object
Adds an on_conflict strategy to the configuration.
299 300 301 302 303 304 305 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 299 def add_strategy(name, klass) strategy_sym = name.to_sym raise DuplicateStrategy, ":#{name} already defined, please use another name" if strategies.key?(strategy_sym) new_strategies = strategies.dup.merge(strategy_sym => klass).freeze self.strategies = new_strategies end |
#class_name ⇒ String
Memoized variable to get the class name
263 264 265 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 263 def class_name @class_name ||= self.class.name end |
#default_lock_timeout ⇒ nil, Integer
Default Lock Timeout
251 252 253 254 255 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 251 def default_lock_timeout warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ " Please use `#{class_name}#lock_timeout` instead." lock_timeout end |
#default_lock_timeout=(obj) ⇒ Integer
Set new value for default_lock_timeout
226 227 228 229 230 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 226 def default_lock_timeout=(obj) warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ " Please use `#{class_name}#lock_timeout=` instead." self.lock_timeout = obj end |
#default_lock_ttl ⇒ nil, Integer
Default lock TTL (Time To Live)
238 239 240 241 242 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 238 def default_lock_ttl warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ " Please use `#{class_name}#lock_ttl` instead." lock_ttl end |
#default_lock_ttl=(obj) ⇒ <type>
Set the default_lock_ttl
212 213 214 215 216 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 212 def default_lock_ttl=(obj) warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \ " Please use `#{class_name}#lock_ttl=` instead." self.lock_ttl = obj end |
#redis_version ⇒ String
The current version of redis
313 314 315 316 |
# File 'lib/sidekiq_unique_jobs/config.rb', line 313 def redis_version self.current_redis_version = SidekiqUniqueJobs.fetch_redis_version if current_redis_version == REDIS_VERSION current_redis_version end |