Sha256: a1ed22be0d823dff8101ad981e6dd572ba27e6e38803262a66d0d665b86a494d

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

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
      include SidekiqUniqueJobs::Reflectable

      # @param [Hash] item sidekiq job hash
      def initialize(item, redis_pool = nil)
        super(item, redis_pool)
        self.job_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_job_class?
          if job_class.set(queue: item["queue"].to_sym).perform_in(5, *item[ARGS])
            reflect(:rescheduled, item)
          else
            reflect(:reschedule_failed, item)
          end
        else
          reflect(:unknown_sidekiq_worker, item)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-8.0.3 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-8.0.2 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-8.0.1 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-8.0.0 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.29 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.24 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.23 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.22 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb
sidekiq-unique-jobs-7.1.21 lib/sidekiq_unique_jobs/on_conflict/reschedule.rb