Sha256: 6881dc874ef837640d5d7bb9eda3b55f33777d29dbecdacfac9274e960d01953

Contents?: true

Size: 1.41 KB

Versions: 108

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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

108 entries across 108 versions & 8 rubygems

Version Path
activejob-6.1.7.10 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.9 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.8 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.7 lib/active_job/queue_adapters/sneakers_adapter.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.6 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.5 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.4 lib/active_job/queue_adapters/sneakers_adapter.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.3 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.2 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7.1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.0.6.1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.7 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.0.6 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.1.6.1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.0.5.1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.2.8.1 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-5.2.8 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob-6.0.5 lib/active_job/queue_adapters/sneakers_adapter.rb