Sha256: 77155fb8bbb9728e5e0e2f3eb4a8668e8fc420d8af2e335a425d3702a52dd706
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module SidekiqUniqueJobs class Lock # 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 # # @author Mikael Henriksson <mikael@mhenrixon.com> class UntilExecuted < 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. # # @yield to the caller when given a block # def lock(&block) unless (token = locksmith.lock) reflect(:lock_failed, item) call_strategy(origin: :client, &block) return end yield if block token end # Executes in the Sidekiq server process # @yield to the worker class perform method def execute locksmith.execute do yield unlock_and_callback end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems