Class: SimpleMutex::SidekiqSupport::JobWrapper
- Inherits:
-
Object
- Object
- SimpleMutex::SidekiqSupport::JobWrapper
- Defined in:
- lib/simple_mutex/sidekiq_support/job_wrapper.rb
Constant Summary collapse
- DEFAULT_EXPIRES_IN =
5 hours
5 * 60 * 60
Instance Attribute Summary collapse
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#lock_key ⇒ Object
readonly
Returns the value of attribute lock_key.
-
#lock_with_params ⇒ Object
readonly
Returns the value of attribute lock_with_params.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(job, params: [], lock_key: nil, lock_with_params: false, expires_in: DEFAULT_EXPIRES_IN) ⇒ JobWrapper
constructor
A new instance of JobWrapper.
- #with_redlock(&block) ⇒ Object
Constructor Details
#initialize(job, params: [], lock_key: nil, lock_with_params: false, expires_in: DEFAULT_EXPIRES_IN) ⇒ JobWrapper
Returns a new instance of JobWrapper.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 10 def initialize(job, params: [], lock_key: nil, lock_with_params: false, expires_in: DEFAULT_EXPIRES_IN) self.job = job self.params = params self.lock_key = lock_key self.lock_with_params = lock_with_params self.expires_in = expires_in end |
Instance Attribute Details
#expires_in ⇒ Object
Returns the value of attribute expires_in.
6 7 8 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 6 def expires_in @expires_in end |
#job ⇒ Object
Returns the value of attribute job.
6 7 8 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 6 def job @job end |
#lock_key ⇒ Object
Returns the value of attribute lock_key.
6 7 8 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 6 def lock_key @lock_key end |
#lock_with_params ⇒ Object
Returns the value of attribute lock_with_params.
6 7 8 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 6 def lock_with_params @lock_with_params end |
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 6 def params @params end |
Instance Method Details
#with_redlock(&block) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/simple_mutex/sidekiq_support/job_wrapper.rb', line 23 def with_redlock(&block) ::SimpleMutex::Mutex.with_lock( lock_key || generate_lock_key, expires_in: expires_in, payload: generate_payload, &block ) end |