Class: SidekiqUniqueJobs::LockTimeout
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::LockTimeout
- Includes:
- SidekiqWorkerMethods
- Defined in:
- lib/sidekiq_unique_jobs/lock_timeout.rb
Overview
Calculates timeout and expiration
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Attributes included from SidekiqWorkerMethods
Class Method Summary collapse
-
.calculate(item) ⇒ Integer
Calculates the timeout for a Sidekiq job.
Instance Method Summary collapse
-
#calculate ⇒ Integer?
Finds a lock timeout in either of default worker options, #default_lock_timeout or provided worker_options.
-
#default_lock_timeout ⇒ Integer?
The configured default_lock_timeout.
-
#initialize(item) ⇒ LockTimeout
constructor
A new instance of LockTimeout.
Methods included from SidekiqWorkerMethods
#after_unlock_hook, #default_job_options, #job_class_constantize, #job_method_defined?, #job_options, #sidekiq_job_class?
Constructor Details
#initialize(item) ⇒ LockTimeout
Returns a new instance of LockTimeout.
32 33 34 35 |
# File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 32 def initialize(item) @item = item self.job_class = item[CLASS] end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
25 26 27 |
# File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 25 def item @item end |
Class Method Details
.calculate(item) ⇒ Integer
Calculates the timeout for a Sidekiq job
19 20 21 |
# File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 19 def self.calculate(item) new(item).calculate end |
Instance Method Details
#calculate ⇒ Integer?
Finds a lock timeout in either of
default worker options, {default_lock_timeout} or provided worker_options
44 45 46 47 48 49 |
# File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 44 def calculate timeout = [LOCK_TIMEOUT] timeout = default_lock_timeout if default_lock_timeout timeout = [LOCK_TIMEOUT] if .key?(LOCK_TIMEOUT) timeout end |
#default_lock_timeout ⇒ Integer?
The configured default_lock_timeout
58 59 60 |
# File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 58 def default_lock_timeout SidekiqUniqueJobs.config.lock_timeout end |