Sha256: 3e06ce5e7a359858c0c324d26d28e5653bb6506d105948889c8fcfdaf0ae7b3d
Contents?: true
Size: 870 Bytes
Versions: 6
Compression:
Stored size: 870 Bytes
Contents
# frozen_string_literal: true module SidekiqUniqueJobs class Lock # Locks jobs until {#execute} starts # - Locks on perform_in or perform_async # - Unlocks before yielding to the worker's perform method # # @author Mikael Henriksson <mikael@mhenrixon.com> class UntilExecuting < BaseLock # # Locks a sidekiq job # # @note Will call a conflict strategy if lock can't be achieved. # # @return [String, nil] the locked jid when properly locked, else nil. # def lock return lock_failed unless (job_id = locksmith.lock) return yield job_id if block_given? job_id end # Executes in the Sidekiq server process # @yield to the worker class perform method def execute callback_safely if locksmith.unlock yield end end end end
Version data entries
6 entries across 6 versions & 1 rubygems