Sha256: 3a438d079c96faa9ce05c07d4ff100e8f662ae75ff0ab393cdc0df2d761a5f32

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  class Lock
    # Locks jobs while the job is executing in the server process
    # - Locks on perform_in or perform_async (see {UntilExecuting})
    # - Unlocks before yielding to the worker's perform method (see {UntilExecuting})
    # - Locks before yielding to the worker's perform method (see {WhileExecuting})
    # - Unlocks after yielding to the worker's perform method (see {WhileExecuting})
    #
    # See {#lock} for more information about the client.
    # See {#execute} for more information about the server
    #
    # @author Mikael Henriksson <mikael@zoolutions.se>
    class UntilAndWhileExecuting < BaseLock
      # Executes in the Sidekiq server process
      # @yield to the worker class perform method
      def execute
        return unless locked?
        unlock

        runtime_lock.execute { yield }
      end

      def runtime_lock
        @runtime_lock ||= SidekiqUniqueJobs::Lock::WhileExecuting.new(item, callback, redis_pool)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-6.0.6 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.5 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.4 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.3 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.2 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.1 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.0 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.0.rc8 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb
sidekiq-unique-jobs-6.0.0.rc7 lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb