Sha256: 00804a92d31a8bda0fb8d7daac34b5ab4dc3f770505e03f9ac71c8300867c48d
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module SidekiqUniqueJobs module OnConflict # Strategy to replace the job on conflict # # @author Mikael Henriksson <mikael@zoolutions.se> class Replace < OnConflict::Strategy attr_reader :queue, :unique_digest # @param [Hash] item sidekiq job hash def initialize(item) super @queue = item[QUEUE_KEY] @unique_digest = item[UNIQUE_DIGEST_KEY] end # Replace the old job in the queue # @yield to retry the lock after deleting the old one def call(&block) return unless delete_job_by_digest delete_lock block&.call end # Delete the job from either schedule, retry or the queue def delete_job_by_digest Scripts.call(:delete_job_by_digest, nil, keys: [queue, unique_digest]) end # Delete the keys belonging to the job def delete_lock Scripts.call(:delete_by_digest, nil, keys: [UNIQUE_SET, unique_digest]) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems