Sha256: 1674e818ac8e0fd5313c6d222fed4788805f94a88f421a8cc03ff5036b7d3320

Contents?: true

Size: 803 Bytes

Versions: 4

Compression:

Stored size: 803 Bytes

Contents

# frozen_string_literal: true

begin
  require "resque"
rescue LoadError
  # Resque is not available, no need to load the adapter
  return
end

module JobIteration
  module InterruptionAdapters
    module ResqueAdapter
      # @private
      module IterationExtension
        def initialize(*)
          $resque_worker = self # rubocop:disable Style/GlobalVars
          super
        end
      end

      # @private
      module ::Resque
        class Worker
          # The patch is required in order to call shutdown? on a Resque::Worker instance
          prepend(IterationExtension)
        end
      end

      class << self
        def call
          $resque_worker.try!(:shutdown?) # rubocop:disable Style/GlobalVars
        end
      end
    end

    register(:resque, ResqueAdapter)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
job-iteration-1.7.0 lib/job-iteration/interruption_adapters/resque_adapter.rb
job-iteration-1.6.0 lib/job-iteration/interruption_adapters/resque_adapter.rb
job-iteration-1.5.1 lib/job-iteration/interruption_adapters/resque_adapter.rb
job-iteration-1.5.0 lib/job-iteration/interruption_adapters/resque_adapter.rb