Class: SidekiqUniqueJobs::Lock::UntilExpired

Inherits:
UntilExecuted show all
Defined in:
lib/sidekiq_unique_jobs/lock/until_expired.rb

Overview

UntilExpired locks until the job expires

Author:

Instance Method Summary collapse

Methods inherited from BaseLock

#initialize, #locksmith, validate_options

Methods included from Reflectable

#reflect

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

Yields:

  • to the worker class perform method



29
30
31
# File 'lib/sidekiq_unique_jobs/lock/until_expired.rb', line 29

def execute(&block)
  locksmith.execute(&block)
end

#lock { ... } ⇒ String?

Note:

Will call a conflict strategy if lock can’t be achieved.

Locks a sidekiq job

Yields:

  • to the caller when given a block

Returns:

  • (String, nil)

    the locked jid when properly locked, else nil.



20
21
22
23
24
25
# File 'lib/sidekiq_unique_jobs/lock/until_expired.rb', line 20

def lock
  return lock_failed unless (job_id = locksmith.lock)
  return yield job_id if block_given?

  job_id
end