Sha256: 6a045c9ffddda6b07788f1c68a770cd0a0f5832ddb934a1371ef7bfcaf6d73e8

Contents?: true

Size: 1.33 KB

Versions: 23

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require "backburner"

module ActiveJob
  module QueueAdapters
    # = Backburner adapter for Active Job
    #
    # Backburner is a beanstalkd-powered job queue that can handle a very
    # high volume of jobs. You create background jobs and place them on
    # multiple work queues to be processed later. Read more about
    # Backburner {here}[https://github.com/nesquena/backburner].
    #
    # To use Backburner set the queue_adapter config to +:backburner+.
    #
    #   Rails.application.config.active_job.queue_adapter = :backburner
    class BackburnerAdapter < AbstractAdapter
      def enqueue(job) # :nodoc:
        response = Backburner::Worker.enqueue(JobWrapper, [job.serialize], queue: job.queue_name, pri: job.priority)
        job.provider_job_id = response[:id] if response.is_a?(Hash)
        response
      end

      def enqueue_at(job, timestamp) # :nodoc:
        delay = timestamp - Time.current.to_f
        response = Backburner::Worker.enqueue(JobWrapper, [job.serialize], queue: job.queue_name, pri: job.priority, delay: delay)
        job.provider_job_id = response[:id] if response.is_a?(Hash)
        response
      end

      class JobWrapper # :nodoc:
        class << self
          def perform(job_data)
            Base.execute job_data
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
activejob-8.0.1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-8.0.0.1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.2.1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-8.0.0 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.2 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-8.0.0.rc2 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.1.2 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-8.0.0.rc1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.1.1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-8.0.0.beta1 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha9 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha8 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha7 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha4 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha3 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha2 lib/active_job/queue_adapters/backburner_adapter.rb
omg-activejob-8.0.0.alpha1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.1 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.0 lib/active_job/queue_adapters/backburner_adapter.rb
activejob-7.2.0.rc1 lib/active_job/queue_adapters/backburner_adapter.rb