Sha256: ae00574790989f7050d95287b31fb4509cce194c31556da05f60e121e503032d

Contents?: true

Size: 1.73 KB

Versions: 16

Compression:

Stored size: 1.73 KB

Contents

module ActiveJob
  module QueueAdapters
    # == Rocket Job adapter for Active Job
    #
    # Ruby's missing batch system.
    #
    # Read more about Rocket Job {here}[http://rocketjob.io].
    #
    # To use Rocket Job set the queue_adapter config to +:rocket_job+.
    #
    #   Rails.application.config.active_job.queue_adapter = :rocket_job
    class RocketJobAdapter
      def enqueue(active_job) #:nodoc:
        rocket_job                 = JobWrapper.perform_later(active_job.serialize) do |job|
          job.active_job_id    = active_job.job_id
          job.active_job_class = active_job.class.name
          job.active_job_queue = active_job.queue_name
          job.description      = active_job.class.name
          job.priority         = active_job.priority if active_job.priority
        end
        active_job.provider_job_id = rocket_job.id.to_s
        rocket_job
      end

      def enqueue_at(active_job, timestamp) #:nodoc:
        rocket_job                 = JobWrapper.perform_later(active_job.serialize) do |job|
          job.active_job_id    = active_job.job_id
          job.active_job_class = active_job.class.name
          job.active_job_queue = active_job.queue_name
          job.description      = active_job.class.name
          job.priority         = active_job.priority if active_job.priority
          job.run_at           = Time.at(timestamp).utc
        end
        active_job.provider_job_id = rocket_job.id.to_s
        rocket_job
      end

      class JobWrapper < RocketJob::Job #:nodoc:
        field :active_job_id, type: String
        field :active_job_class, type: String
        field :active_job_queue, type: String

        def perform(job_data)
          Base.execute job_data
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rocketjob-3.1.0 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.5 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.4 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.3 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.2 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.1 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.rc5 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.rc4 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.rc3 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.rc2 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.rc1 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.beta3 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.beta2 lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.beta lib/rocket_job/extensions/rocket_job_adapter.rb
rocketjob-3.0.0.alpha lib/rocket_job/extensions/rocket_job_adapter.rb