Class: SidekiqUniqueJobs::Lock::BaseLock Abstract
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::Lock::BaseLock
- Extended by:
- Forwardable
- Includes:
- SidekiqUniqueJobs::Logging, Reflectable
- Defined in:
- lib/sidekiq_unique_jobs/lock/base_lock.rb
Overview
Abstract base class for locks
Direct Known Subclasses
UntilAndWhileExecuting, UntilExecuted, UntilExecuting, WhileExecuting
Class Method Summary collapse
-
.validate_options(options = {}) ⇒ void
Validates that the sidekiq_options for the worker is valid.
Instance Method Summary collapse
-
#execute ⇒ Object
Execute the job in the Sidekiq server processor.
-
#initialize(item, callback, redis_pool = nil) ⇒ BaseLock
constructor
A new instance of BaseLock.
-
#lock { ... } ⇒ String?
Locks a sidekiq job.
-
#locksmith ⇒ SidekiqUniqueJobs::Locksmith
private
The lock manager/client.
Methods included from Reflectable
Methods included from SidekiqUniqueJobs::Logging
#build_message, included, #log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context, #with_configured_loggers_context, #with_logging_context
Constructor Details
#initialize(item, callback, redis_pool = nil) ⇒ BaseLock
Returns a new instance of BaseLock.
38 39 40 41 42 43 44 45 |
# File 'lib/sidekiq_unique_jobs/lock/base_lock.rb', line 38 def initialize(item, callback, redis_pool = nil) @item = item @callback = callback @redis_pool = redis_pool @attempt = 0 prepare_item # Used to ease testing @lock_config = LockConfig.new(item) end |
Class Method Details
Instance Method Details
#execute ⇒ Object
Execute the job in the Sidekiq server processor
62 63 64 |
# File 'lib/sidekiq_unique_jobs/lock/base_lock.rb', line 62 def execute raise NotImplementedError, "##{__method__} needs to be implemented in #{self.class}" end |
#lock { ... } ⇒ String?
Will call a conflict strategy if lock can’t be achieved.
Locks a sidekiq job
56 57 58 |
# File 'lib/sidekiq_unique_jobs/lock/base_lock.rb', line 56 def lock raise NotImplementedError, "##{__method__} needs to be implemented in #{self.class}" end |
#locksmith ⇒ SidekiqUniqueJobs::Locksmith
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The lock manager/client
72 73 74 |
# File 'lib/sidekiq_unique_jobs/lock/base_lock.rb', line 72 def locksmith @locksmith ||= SidekiqUniqueJobs::Locksmith.new(item, redis_pool) end |