Class: SidekiqUniqueJobs::Lock::UntilExecuted
- Defined in:
- lib/sidekiq_unique_jobs/lock/until_executed.rb
Overview
Locks jobs until the server is done executing the job
-
Locks on perform_in or perform_async
-
Unlocks after yielding to the worker’s perform method
Direct Known Subclasses
Instance Method Summary collapse
-
#execute { ... } ⇒ Object
Executes in the Sidekiq server process.
-
#lock { ... } ⇒ String?
Locks a sidekiq job.
Methods inherited from BaseLock
#initialize, #locksmith, validate_options
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
This class inherits a constructor from SidekiqUniqueJobs::Lock::BaseLock
Instance Method Details
#execute { ... } ⇒ Object
Executes in the Sidekiq server process
29 30 31 32 33 34 |
# File 'lib/sidekiq_unique_jobs/lock/until_executed.rb', line 29 def execute locksmith.execute do yield unlock_and_callback end end |
#lock { ... } ⇒ String?
Note:
Will call a conflict strategy if lock can’t be achieved.
Locks a sidekiq job
20 21 22 23 24 25 |
# File 'lib/sidekiq_unique_jobs/lock/until_executed.rb', line 20 def lock return lock_failed(origin: :client) unless (token = locksmith.lock) return yield token if block_given? token end |