Sha256: 3cabca4df8727d402923d222e9587c3d4cb7b948309f2c24ec91bdd1839145f9

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

module Sidekiq
  class Client

    ##
    # The Sidekiq inline infrastructure overrides perform_async so that it
    # actually calls perform instead. This allows workers to be run inline in a
    # testing environment.
    #
    # This is similar to `Resque.inline = true` functionality.
    #
    # Example:
    #
    #   require 'sidekiq/testing/inline'
    #
    #   $external_variable = 0
    #
    #   class ExternalWorker
    #     include Sidekiq::Worker
    #
    #     def perform
    #       $external_variable = 1
    #     end
    #   end
    #
    #   assert_equal 0, $external_variable
    #   ExternalWorker.perform_async
    #   assert_equal 1, $external_variable
    #
    singleton_class.class_eval do
      alias_method :raw_push_old, :raw_push
      def raw_push(payload)
        [payload].flatten.each do |item|
          marshalled = Sidekiq.load_json(Sidekiq.dump_json(item))
          marshalled['class'].constantize.new.perform(*marshalled['args'])
        end

        true
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
sidekiq-2.14.1 lib/sidekiq/testing/inline.rb
sidekiq-2.14.0 lib/sidekiq/testing/inline.rb
sidekiq-2.13.1 lib/sidekiq/testing/inline.rb
sidekiq-2.13.0 lib/sidekiq/testing/inline.rb
sidekiq-2.12.4 lib/sidekiq/testing/inline.rb
sidekiq-2.12.3 lib/sidekiq/testing/inline.rb
sidekiq-2.12.1 lib/sidekiq/testing/inline.rb
sidekiq-2.12.0 lib/sidekiq/testing/inline.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/testing/inline.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/testing/inline.rb
sidekiq-2.11.2 lib/sidekiq/testing/inline.rb
sidekiq-2.11.1 lib/sidekiq/testing/inline.rb
sidekiq-2.11.0 lib/sidekiq/testing/inline.rb
sidekiq-2.10.1 lib/sidekiq/testing/inline.rb
sidekiq-2.10.0 lib/sidekiq/testing/inline.rb
sidekiq-2.9.0 lib/sidekiq/testing/inline.rb