Sha256: 3018dfe77a93831cd346986dffebf3dd367a19d86e3fc48a68121167e72991d6

Contents?: true

Size: 966 Bytes

Versions: 14

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module OnConflict
    # Strategy to reschedule job on conflict
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    class Reschedule < OnConflict::Strategy
      include SidekiqUniqueJobs::SidekiqWorkerMethods
      include SidekiqUniqueJobs::Logging
      include SidekiqUniqueJobs::JSON

      # @param [Hash] item sidekiq job hash
      def initialize(item, redis_pool = nil)
        super(item, redis_pool)
        @worker_class = item[CLASS]
      end

      # Create a new job from the current one.
      #   This will mess up sidekiq stats because a new job is created
      def call
        if sidekiq_worker_class?
          log_info("Rescheduling #{item[LOCK_DIGEST]}")
          worker_class.perform_in(5, *item[ARGS])
        else
          log_warn("Skip rescheduling of #{item[LOCK_DIGEST]} because #{worker_class} is not a Sidekiq::Worker")
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.0.13 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.12 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.11 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.10 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.9 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.8 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.7 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.6 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.5 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.4 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.3 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.2 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.1 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.0.0 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb