Sha256: d5ac8b3b275960516e4f8218412b510b940deb9bec2f3ea63dc66379e5901399

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 Bytes

Contents

require 'sneakers'
require 'thread'

module ActiveJob
  module QueueAdapters
    class SneakersAdapter
      @monitor = Monitor.new

      class << self
        def enqueue(job)
          @monitor.synchronize do
            JobWrapper.from_queue job.queue_name
            JobWrapper.enqueue ActiveSupport::JSON.encode(job.serialize)
          end
        end

        def enqueue_at(job, timestamp)
          raise NotImplementedError
        end
      end

      class JobWrapper
        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

5 entries across 5 versions & 2 rubygems

Version Path
activejob_backport-0.0.3 lib/active_job/queue_adapters/sneakers_adapter.rb
passive_job-0.0.3 lib/active_job/queue_adapters/sneakers_adapter.rb
passive_job-0.0.2 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob_backport-0.0.2 lib/active_job/queue_adapters/sneakers_adapter.rb
activejob_backport-0.0.1 lib/active_job/queue_adapters/sneakers_adapter.rb