Sha256: abe099bb2b858b72f1462be20fc20695d21bd4982d79674ee36c0e348dc2636e

Contents?: true

Size: 1.38 KB

Versions: 35

Compression:

Stored size: 1.38 KB

Contents

require 'sneakers'
require 'monitor'

module ActiveJob
  module QueueAdapters
    # == Sneakers adapter for Active Job
    #
    # A high-performance RabbitMQ background processing framework for Ruby.
    # Sneakers is being used in production for both I/O and CPU intensive
    # workloads, and have achieved the goals of high-performance and
    # 0-maintenance, as designed.
    #
    # Read more about Sneakers {here}[https://github.com/jondot/sneakers].
    #
    # To use Sneakers set the queue_adapter config to +:sneakers+.
    #
    #   Rails.application.config.active_job.queue_adapter = :sneakers
    class SneakersAdapter
      def initialize
        @monitor = Monitor.new
      end

      def enqueue(job) #:nodoc:
        @monitor.synchronize do
          JobWrapper.from_queue job.queue_name
          JobWrapper.enqueue ActiveSupport::JSON.encode(job.serialize)
        end
      end

      def enqueue_at(job, timestamp) #:nodoc:
        raise NotImplementedError, "This queueing backend does not support scheduling jobs. To see what features are supported go to http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html"
      end

      class JobWrapper #:nodoc:
        include Sneakers::Worker
        from_queue 'default'

        def work(msg)
          job_data = ActiveSupport::JSON.decode(msg)
          Base.execute job_data
          ack!
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 4 rubygems

Version Path
activejob-5.0.7.2 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.7.1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.7 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.6 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.6.rc1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.5 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.5.rc2 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.5.rc1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.4 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.4.rc1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.3 lib/active_job/queue_adapters/sneakers_adapter.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activejob-5.0.2/lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.2 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.0.2.rc1 lib/active_job/queue_adapters/sneakers_adapter.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_adapters/sneakers_adapter.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_adapters/sneakers_adapter.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_adapters/sneakers_adapter.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_adapters/sneakers_adapter.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_adapters/sneakers_adapter.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_adapters/sneakers_adapter.rb